/* Minute Shipdick — neobrutalist look cloned from minutecryptic.com */

:root {
  --bg: #add3ff; /* sampled from minutecryptic.com */
  --card: #ffffff;
  --ink: #16161a;
  --pink: #f9c8f5;
  --pink-soft: #fbdcf8;
  --yellow: #fbe7a0;
  --yellow-soft: #fdf0c4;
  --blue-hl: #bbd8fe;
  --purple: #d9c8fb;
  --grey: #e9e9ee;
  --radius: 12px;
  --border: 2.5px solid var(--ink);
  --shadow: 4px 4px 0 var(--ink);
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --font-fancy: Georgia, "Times New Roman", serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100dvh;
  padding-bottom: 190px; /* room for fixed keyboard */
}

/* ---------- top bar ---------- */
.topbar {
  width: 100%;
  max-width: 560px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
}
.topbar-date { font-weight: 700; font-size: 16px; }
.topbar-setter { font-size: 12px; opacity: 0.75; }
.topbar-logo { font-weight: 800; font-size: 16px; }

/* ---------- layout ---------- */
.game {
  width: 100%;
  max-width: 600px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 14px;
  gap: 36px;
}

/* ---------- clue ---------- */
.clue-card {
  width: 100%;
  background: var(--card);
  border-radius: 14px;
  padding: 30px 30px;
  box-shadow: 0 1px 4px rgba(22, 22, 26, 0.12);
  margin-top: 6px;
}
.clue-text {
  font-size: 23px;
  line-height: 1.5;
  text-align: left;
}
.hl {
  border-radius: 4px;
  padding: 1px 2px;
  margin: -1px -2px;
}
.hl-indicators { background: var(--pink); }
.hl-fodder { background: var(--yellow); }
.hl-definition { background: var(--blue-hl); }

/* ---------- answer tiles ---------- */
.tiles {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
  row-gap: 10px;
}
.tile-word { display: flex; }
.tile {
  width: 50px;
  height: 52px;
  background: var(--card);
  border: var(--border);
  border-left-width: 1.25px;
  border-right-width: 1.25px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-fancy);
  font-style: italic;
  font-weight: 700;
  font-size: 30px;
  text-transform: lowercase;
  cursor: pointer;
  user-select: none;
}
.tile:first-child { border-left-width: 2.5px; border-radius: 6px 0 0 6px; }
.tile:last-child { border-right-width: 2.5px; border-radius: 0 6px 6px 0; }
.tile:only-child { border-radius: 6px; }
.tile.active { background: var(--pink); }
.tile.revealed { background: var(--purple); }
.tiles.solved .tile { background: var(--pink-soft); }
.tiles.shake { animation: shake 0.45s; }
.tile.pop { animation: pop 0.5s cubic-bezier(0.28, 1.6, 0.5, 1) both; }
@keyframes pop {
  0% { transform: translateY(0) scale(1); }
  40% { transform: translateY(-14px) scale(1.12); }
  100% { transform: translateY(0) scale(1); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px); }
  40% { transform: translateX(7px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}

/* ---------- par dots (during play) ---------- */
.par-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 18px; /* room for the "par" label below its dot */
}
.par-dot {
  position: relative;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
}
.par-dot.used-indicators { background: var(--pink); border: 2px solid var(--ink); }
.par-dot.used-fodder { background: var(--yellow); border: 2px solid var(--ink); }
.par-dot.used-definition { background: var(--blue-hl); border: 2px solid var(--ink); }
.par-dot.used-letter { background: var(--purple); border: 2px solid var(--ink); }
.par-dot.par-mark { background: #fff; border: 2.5px solid var(--ink); }
.par-dot.par-mark::after {
  content: "par";
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-fancy);
  font-style: italic;
  font-weight: 700;
  font-size: 19px;
}
body.finished .par-row { display: none; }

/* ---------- buttons ---------- */
.actions {
  display: flex;
  align-items: center;
  gap: 14px;
}
.btn {
  font-family: var(--font-fancy);
  font-style: italic;
  font-weight: 700;
  font-size: 20px;
  color: var(--ink);
  background: var(--card);
  border: var(--border);
  cursor: pointer;
  transition: transform 0.06s;
}
.btn:active:not(:disabled) { transform: translate(3px, 3px); box-shadow: none !important; }
.btn:disabled {
  color: #9a9aa4;
  border-color: #9a9aa4;
  box-shadow: none !important;
  cursor: default;
  background: transparent;
}
.btn-pill {
  border-radius: 999px;
  padding: 11px 36px;
  box-shadow: var(--shadow);
}
.btn-hints { background: var(--yellow); }
.btn-share { background: var(--pink); }
.btn-round {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  box-shadow: var(--shadow);
  font-size: 19px;
  font-style: normal;
}

/* ---------- scribble space ---------- */
/* In-flow card below the clue/tiles/par — never covers them. */
.scribble-panel {
  width: 100%;
  height: min(46vh, 400px);
  background: var(--card);
  border: 3px solid var(--ink);
  border-radius: 16px;
  box-shadow: 5px 5px 0 var(--ink);
  display: flex;
  flex-direction: column;
  padding: 12px 16px 8px;
}
.scribble-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.scribble-title {
  font-family: var(--font-fancy);
  font-style: italic;
  font-weight: 700;
  font-size: 19px;
}
.scribble-tools { display: flex; gap: 8px; }
.tool-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  background: var(--card);
  cursor: pointer;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 2px 2px 0 var(--ink);
}
.tool-btn svg { width: 17px; height: 17px; }
.tool-btn:active { transform: translate(2px, 2px); box-shadow: none; }
.tool-btn.active { background: var(--yellow); }
.scribble-canvas {
  position: relative;
  flex: 1;
  overflow: hidden;
  touch-action: none;
}
.scribble-tile {
  position: absolute;
  width: 40px;
  height: 42px;
  background: var(--card);
  border: 2.5px solid var(--ink);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-fancy);
  font-style: italic;
  font-weight: 700;
  font-size: 24px;
  text-transform: lowercase;
  cursor: grab;
  user-select: none;
  touch-action: none;
  box-shadow: 2px 2px 0 var(--ink);
}
.scribble-tile.newest { background: var(--purple); }
.scribble-tile.dragging { cursor: grabbing; z-index: 5; box-shadow: 4px 4px 0 var(--ink); }
.scribble-help {
  font-size: 12px;
  opacity: 0.55;
  text-align: center;
  padding-top: 6px;
}
/* while scribbling, the buttons row gives way to the panel */
body.scribbling .actions { display: none; }

/* ---------- result card ---------- */
.result-card { animation: rise-in 0.45s cubic-bezier(0.2, 1.1, 0.4, 1) both; }
@keyframes rise-in {
  from { opacity: 0; transform: translateY(22px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .result-card, .tile.pop, .tiles.shake { animation: none !important; }
}
.result-card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border: 3px solid var(--ink);
  border-radius: 16px;
  box-shadow: 5px 5px 0 var(--ink);
  padding: 20px 22px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.result-dots {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 7px;
}
.result-dot {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid #b48ad6;
  background: transparent;
}
.result-dot.used-indicators { background: var(--pink); border-color: var(--ink); }
.result-dot.used-fodder { background: var(--yellow); border-color: var(--ink); }
.result-dot.used-definition { background: var(--blue-hl); border-color: var(--ink); }
.result-dot.used-letter { background: var(--purple); border-color: var(--ink); }
.result-title { font-size: 24px; font-weight: 800; }
.result-par { font-size: 14px; opacity: 0.85; }

/* ---------- hint explanation ---------- */
.hint-explain {
  position: relative;
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border: 3px solid var(--ink);
  border-radius: 14px;
  box-shadow: 5px 5px 0 var(--ink);
  padding: 18px 40px 18px 18px;
  font-size: 15px;
  line-height: 1.5;
}
.explain-close {
  position: absolute;
  top: 10px;
  right: 10px;
  border: none;
  background: none;
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
  color: var(--ink);
}

/* ---------- hint sheet ---------- */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(22, 22, 26, 0.25);
  z-index: 40;
}
.hint-sheet {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 24px;
  width: min(92vw, 380px);
  background: var(--card);
  border: 3px solid var(--ink);
  border-radius: 14px;
  box-shadow: 5px 5px 0 var(--ink);
  padding: 14px 18px 10px;
  z-index: 50;
}
.sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  opacity: 0.9;
  margin-bottom: 4px;
}
.sheet-close {
  border: none;
  background: none;
  font-size: 17px;
  font-weight: 800;
  cursor: pointer;
  color: var(--ink);
}
.sheet-option {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-top: 1px solid #e4e4ea;
  font-family: var(--font-fancy);
  font-style: italic;
  font-weight: 700;
  font-size: 19px;
  padding: 12px 2px;
  cursor: pointer;
  color: var(--ink);
}
.sheet-option:first-child { border-top: none; }
.sheet-option .swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 1.5px solid var(--ink);
  margin-left: 8px;
  vertical-align: baseline;
}
.sheet-option.divider { border-top: 2.5px solid var(--ink); }
.sheet-option:disabled { color: #9a9aa4; cursor: default; }
.sheet-option .tag {
  font-family: var(--font-body);
  font-style: normal;
  font-weight: 600;
  font-size: 11px;
  opacity: 0.65;
  margin-left: 8px;
}

/* ---------- keyboard ---------- */
.keyboard {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 10px 6px calc(12px + env(safe-area-inset-bottom));
  background: var(--bg);
  z-index: 30;
}
.kb-row { display: flex; gap: 6px; justify-content: center; width: 100%; max-width: 520px; }
.kb-key {
  flex: 1;
  max-width: 46px;
  height: 48px;
  background: var(--card);
  border: 1.5px solid var(--ink);
  border-radius: 7px;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  color: var(--ink);
  box-shadow: 0 1.5px 0 var(--ink);
}
.kb-key:active { transform: translateY(1.5px); box-shadow: none; }
.kb-key.wide { max-width: 70px; flex: 1.6; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  bottom: 210px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  padding: 9px 18px;
  border-radius: 999px;
  z-index: 60;
  pointer-events: none;
}

.hidden { display: none !important; }

/* game finished: hide input chrome */
body.finished .keyboard,
body.finished .actions,
body.finished .scribble-panel { display: none; }
body.finished { padding-bottom: 40px; }

.topbar { max-width: 600px; }

@media (max-width: 420px) {
  .tile { width: 42px; height: 46px; font-size: 25px; }
  .clue-text { font-size: 19px; }
  .clue-card { padding: 20px 20px; }
}
