/* Tuxword. Same Catppuccin Macchiato / Latte palette as Tuxdle. */
:root {
  --base: #24273a; --mantle: #1e2030; --crust: #181926;
  --surface0: #363a4f; --surface1: #494d64; --surface2: #5b6078;
  --overlay0: #6e738d; --text: #cad3f5; --subtext0: #a5adcb;
  --green: #a6da95; --yellow: #eed49f; --red: #ed8796; --blue: #8aadf4;
  --mauve: #c6a0f6; --lavender: #b7bdf8; --peach: #f5a97f; --teal: #8bd5ca;
  --tile: #cad3f5; --tile-ink: #1e2030; --tile-edge: #939ab7;
  --c: 36px; /* board cell size, set from JS */
}
:root[data-theme="light"] {
  --base: #eff1f5; --mantle: #e6e9ef; --crust: #dce0e8;
  --surface0: #ccd0da; --surface1: #bcc0cc; --surface2: #acb0be;
  --overlay0: #9ca0b0; --text: #4c4f69; --subtext0: #6c6f85;
  --green: #40a02b; --yellow: #df8e1d; --red: #d20f39; --blue: #1e66f5;
  --mauve: #8839ef; --lavender: #7287fd; --peach: #fe640b; --teal: #179299;
  --tile: #ffffff; --tile-ink: #4c4f69; --tile-edge: #9ca0b0;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--base);
  color: var(--text);
  font-family: "JetBrains Mono", "Fira Code", ui-monospace, Menlo, Consolas, monospace;
  display: flex; flex-direction: column; align-items: center;
  min-height: 100dvh;
  overscroll-behavior: none;
}
.hidden { display: none !important; }
a { color: var(--blue); }

header {
  width: 100%; max-width: 520px; height: 48px; padding: 0 12px;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 6px;
}
header .side { display: flex; gap: 2px; }
header nav.side { justify-self: end; }
header h1 { font-size: 1.15rem; letter-spacing: 0.3em; color: var(--lavender); white-space: nowrap; }
header h1 small { font-size: 0.7rem; letter-spacing: 0.05em; color: var(--subtext0); font-weight: 400; }
.icon-btn {
  width: 36px; height: 36px; display: grid; place-items: center;
  background: none; border: none; color: var(--text); font: inherit; font-size: 1.05rem;
  border-radius: 8px; cursor: pointer; text-decoration: none;
}
.icon-btn:hover { background: var(--surface0); }

#bar {
  width: 100%; max-width: 520px; height: 44px; padding: 0 12px;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
}
#timer {
  font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums;
  background: var(--mantle); border: 1px solid var(--surface0); border-radius: 999px; padding: 3px 16px;
}
#timer.low { color: var(--red); border-color: var(--red); }
#timer.hit { animation: hit 0.6s; }
@keyframes hit { 30% { color: var(--red); transform: scale(1.15); } }
#btn-hint, #btn-clue {
  justify-self: end;
  background: var(--surface0); color: var(--text); border: 1px solid var(--surface1);
  border-radius: 8px; padding: 6px 12px; font: inherit; font-size: 0.85rem; cursor: pointer;
}
#btn-clue { justify-self: start; }
#btn-hint small, #btn-clue small { color: var(--peach); }
#btn-hint:disabled, #btn-clue:disabled { opacity: 0.4; cursor: default; }
#btn-clue.locked small { color: var(--subtext0); }

#clues { width: 100%; max-width: 520px; padding: 2px 12px 4px; }
#clues p { font-size: 0.78rem; line-height: 1.35; color: var(--text); padding: 2px 0; }
#clues b { color: var(--teal); font-weight: 700; margin-right: 4px; }

/* Archive list and Pro note */
.days { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 6px; text-align: center; }
.days button {
  background: var(--mantle); color: var(--text); border: 1px solid var(--surface0); border-radius: 8px;
  padding: 7px 2px; font: inherit; font-size: 0.8rem; cursor: pointer;
}
.days button span { display: block; font-size: 0.65rem; color: var(--subtext0); margin-top: 2px; }
.days button.solved { border-color: var(--green); }
.days button.timeout { border-color: var(--red); }
.days button.locked { opacity: 0.6; }
.pro-note { background: var(--mantle); border: 1px solid var(--mauve); border-radius: 10px; padding: 12px; margin-top: 12px; }
.pro-note a.go {
  display: inline-block; margin-top: 8px; background: var(--mauve); color: var(--crust); font-weight: 700;
  text-decoration: none; border-radius: 8px; padding: 8px 14px; font-size: 0.85rem;
}

main { flex: 1; display: flex; align-items: flex-start; justify-content: center; width: 100%; padding: 6px 0 10px; }

#board {
  position: relative;
  width: calc(var(--c) * 10); height: calc(var(--c) * 13);
  border-radius: 10px;
  background-color: var(--mantle);
  background-image:
    linear-gradient(var(--surface0) 1px, transparent 1px),
    linear-gradient(90deg, var(--surface0) 1px, transparent 1px);
  background-size: var(--c) var(--c);
  background-position: -0.5px -0.5px;
  outline: 1px solid var(--surface0);
  overflow: hidden;
  touch-action: none; user-select: none; -webkit-user-select: none;
}

.piece {
  position: absolute; left: 0; top: 0; width: 0; height: 0;
  transform: translate(calc(var(--x) * var(--c)), calc(var(--y) * var(--c)));
  transition: transform 0.14s ease-out;
  z-index: 1;
}
.piece.drag { transition: none; z-index: 5; }
.piece.slow { transition: transform 0.9s cubic-bezier(.3,.9,.3,1); }
.tile {
  position: absolute;
  left: calc(var(--dx) * var(--c)); top: calc(var(--dy) * var(--c));
  width: var(--c); height: var(--c);
  display: grid; place-items: center;
  background: var(--tile); color: var(--tile-ink);
  border: 1px solid var(--tile-edge);
  font-weight: 700; font-size: calc(var(--c) * 0.5);
  cursor: grab; touch-action: none;
}
.piece.drag .tile { cursor: grabbing; box-shadow: 0 6px 14px rgba(0,0,0,0.45); }
.piece.joined .tile { background: color-mix(in srgb, var(--green) 30%, var(--tile)); border-color: var(--green); }
.piece.pop .tile { animation: pop 0.45s; }
@keyframes pop { 40% { background: var(--green); transform: scale(1.08); } }
.piece.hint { z-index: 4; }
.piece.hint .tile { animation: hint 0.5s 5 alternate; }
@keyframes hint { to { background: var(--yellow); border-color: var(--peach); } }
.piece.bad .tile { animation: bad 0.3s; }
@keyframes bad { 50% { background: var(--red); } }
#board.done .tile { cursor: default; }
#board.lost .tile { background: color-mix(in srgb, var(--red) 18%, var(--tile)); border-color: var(--red); }

#overlay {
  position: fixed; inset: 0; z-index: 20;
  background: color-mix(in srgb, var(--crust) 80%, transparent);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
#card {
  width: 100%; max-width: 400px; max-height: 100%; overflow-y: auto;
  background: var(--base); border: 1px solid var(--surface1); border-radius: 14px;
  padding: 22px 20px; text-align: center;
}
#card h2 { color: var(--lavender); font-size: 1.3rem; margin-bottom: 6px; }
#card h3 { font-size: 0.75rem; color: var(--subtext0); font-weight: 400; text-transform: uppercase; letter-spacing: 0.1em; margin: 18px 0 8px; }
#card p { font-size: 0.85rem; line-height: 1.5; color: var(--subtext0); margin: 6px 0; }
#card p.big { font-size: 1rem; color: var(--text); }
#card .time { font-size: 2.2rem; font-weight: 700; color: var(--green); font-variant-numeric: tabular-nums; }
#card .time.lost { color: var(--red); }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.grid4 div { background: var(--mantle); border-radius: 8px; padding: 8px 2px; }
.grid4 b { display: block; font-size: 1.15rem; color: var(--text); }
.grid4 span { font-size: 0.62rem; color: var(--subtext0); }
.crowd { background: var(--mantle); border-radius: 8px; padding: 10px; }
.crowd p { margin: 2px 0 !important; color: var(--text) !important; }
ul.words { list-style: none; text-align: left; }
ul.words li { padding: 6px 0; border-bottom: 1px solid var(--surface0); font-size: 0.8rem; color: var(--subtext0); }
ul.words li:last-child { border: none; }
ul.words b { color: var(--teal); text-transform: uppercase; letter-spacing: 0.08em; margin-right: 6px; }
ol.how { text-align: left; font-size: 0.85rem; line-height: 1.5; color: var(--subtext0); padding-left: 22px; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 18px; }
.btns button {
  background: var(--surface0); color: var(--text); border: 1px solid var(--surface1);
  border-radius: 10px; padding: 10px 16px; font: inherit; font-size: 0.9rem; cursor: pointer;
}
.btns button.primary { background: var(--mauve); color: var(--crust); border: none; font-weight: 700; flex: 1 1 100%; padding: 13px; font-size: 1rem; }
.btns button:disabled { opacity: 0.5; }
.fine { font-size: 0.72rem !important; }

#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 30;
  background: var(--text); color: var(--base); padding: 8px 16px; border-radius: 8px; font-size: 0.85rem;
}

/* account card */
.login { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.login input {
  font: inherit; font-size: 1rem; padding: 11px 12px; border-radius: 8px;
  border: 1px solid var(--surface1); background: var(--mantle); color: var(--text);
}
.login button {
  padding: 12px; border: none; border-radius: 10px; background: var(--mauve); color: var(--crust);
  font: inherit; font-size: 1rem; font-weight: 700; cursor: pointer;
}
@media (max-width: 380px) {
  header { padding: 0 6px; }
  header h1 { letter-spacing: 0.15em; }
}
