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

html { background: #3B520C; }

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: transparent;
  color: #f0ede6;
}

#bg-canvas {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: -1;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

#grid {
  display: none;
  position: fixed;
  gap: 0;
  z-index: 1;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

.screen { display: none; flex-direction: column; flex: 1; overflow: hidden; }
.screen.active { display: flex; }

#hero {
  display: grid;
  grid-template-columns: minmax(52px, 1fr) auto minmax(52px, 1fr);
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  position: relative;

  background: linear-gradient(
    180deg,
    rgba(0, 0, 0, 0.62) 0%,
    rgba(0, 0, 0, 0.44) 100%
  );
  backdrop-filter: blur(14px) saturate(1.3);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);

  box-shadow:
    inset 0 1px 0 #3B520C,
    0 1px 0 rgba(255, 255, 255, 0.07),
    0 4px 24px rgba(0, 0, 0, 0.35);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
  z-index: 100;
  transition: padding 0.18s ease;
}

.hero-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 0;
}

.wordmark {
  font-family: 'Jersey 25', sans-serif;
  font-size: 2.6rem;
  color: #f0e4a8;
  letter-spacing: 0.08em;
  line-height: 1;

  text-shadow:
    0 0 30px rgba(240, 210, 80, 0.28),
    0 0 8px  rgba(240, 210, 80, 0.15),
    0 2px 6px rgba(0, 0, 0, 0.55);
  transition: font-size 0.18s ease;
  white-space: nowrap;
}

#hero.hero--compact { padding: 8px 14px; }
#hero.hero--compact .wordmark { font-size: 1.15rem; letter-spacing: 0.06em; }

#game-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.72rem;
}
#game-title {
  color: #e8d9a0;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
#game-difficulty {
  color: rgba(255,255,255,0.4);
  text-transform: capitalize;
  font-size: 0.68rem;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 4px;
  padding: 1px 6px;
  letter-spacing: 0.1em;
}
#game-difficulty:empty {visibility:hidden;}

.hero-actions {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.icon-btn {
  position: relative;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.14);
  cursor: pointer;
  width: 32px;
  height: 32px;
  padding: 0;
  color: #e8d9a0;
  border-radius: 8px;
  line-height: 0;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 1px 3px rgba(0, 0, 0, 0.3);
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.icon-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.24);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.15),
    0 2px 6px rgba(0, 0, 0, 0.35);
}
.icon-btn:active {
  background: rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);
}

.hero--compact .hero-actions { flex-direction: row; gap: 6px; }
.hero--compact .icon-btn { width: 28px; height: 28px; }
.hero--compact .icon-btn svg { width: 16px; height: 16px; }

.hero-game-only { display: none; }
#app[data-screen="game"] .hero-game-only { display: inline-flex; align-items: center; }
#app[data-screen="game"] div.hero-game-only { display: flex; }

#btn-back {
  justify-self: start;
  display: inline-flex !important;
  visibility: hidden;
  pointer-events: none;
}
#app[data-screen="game"] #btn-back {
  visibility: visible;
  pointer-events: auto;
}

#screen-home {
  padding: 0 16px calc(2 * 48px);
  gap: 10px;
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
  justify-content: flex-end;
}

#home-date {
  font-size: 0.7rem;
  color: rgba(240, 217, 160, 0.65);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
#app[data-screen="game"] #home-date { display: none; }

#puzzle-tiles {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.puzzle-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  padding: 16px 20px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 14px;
  cursor: pointer;
  background: rgba(10, 22, 6, 0.68);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.45);
  transition: background 0.15s, border-color 0.15s;
}
.puzzle-tile:hover { background: rgba(10, 22, 6, 0.92); }

.puzzle-tile.puzzle-tile-empty { cursor: default; pointer-events: none; }
.puzzle-tile.puzzle-tile-empty .tile-word { opacity: 0.35; }
.puzzle-tile.puzzle-tile-empty .tile-hint { opacity: 0.4; }

.puzzle-tile[data-diff="easy"]   { border-color: rgba(90,  200, 120, 0.45); }
.puzzle-tile[data-diff="medium"] { border-color: rgba(200, 180,  80, 0.45); }
.puzzle-tile[data-diff="hard"]   { border-color: rgba(220,  80,  80, 0.45); }

.tile-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
}
.puzzle-tile[data-diff="easy"]   .tile-label { color: #7aca8a; }
.puzzle-tile[data-diff="medium"] .tile-label { color: #c8b870; }
.puzzle-tile[data-diff="hard"]   .tile-label { color: #f08a8a; }

.tile-word {
  font-family: 'Jersey 25', sans-serif;
  font-size: 2.2rem;
  color: #e8d9a0;
  letter-spacing: 0.04em;
  line-height: 1.1;
}

.tile-hint {
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.32);
  margin-top: 2px;
}

.tile-status {
  position: absolute;
  top: 10px;
  right: 12px;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
}
.puzzle-tile[data-diff="easy"]   .tile-status--started { color: #7aca8a; }
.puzzle-tile[data-diff="medium"] .tile-status--started { color: #c8b870; }
.puzzle-tile[data-diff="hard"]   .tile-status--started { color: #f08a8a; }
.tile-status--won { color: #5aaa6a; font-size: 1.1rem; }

#game-layout {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

#game-area { flex: 1; }

#clue-panel {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  background: linear-gradient(
    180deg,
    rgba(0, 0, 0, 0.58) 0%,
    rgba(0, 0, 0, 0.44) 100%
  );
  backdrop-filter: blur(12px) saturate(1.2);
  -webkit-backdrop-filter: blur(12px) saturate(1.2);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

#clue-panel-header {
  display: none;
  align-items: baseline;
  gap: 10px;
  padding: 16px 18px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
}
#panel-theme {
  font-family: 'Jersey 25', sans-serif;
  font-size: 1.4rem;
  color: #f0e4a8;
  letter-spacing: 0.06em;
  line-height: 1;
  text-shadow: 0 0 16px rgba(240, 210, 80, 0.2), 0 1px 4px rgba(0,0,0,0.5);
}
#panel-diff {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: rgba(255, 255, 255, 0.38);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  padding: 2px 6px;
}

#clue-bar {

  padding: 10px 14px;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  background: rgba(50, 110, 230, 0.13);
}
#clue-bar-meta {

  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  flex-shrink: 0;
  background: rgba(200, 180, 80, 0.12);
  border: 1px solid rgba(200, 180, 80, 0.22);
  border-radius: 6px;
  padding: 5px 10px;
  min-width: 42px;
}
#clue-number {
  font-weight: 700;
  white-space: nowrap;
  color: #c8b870;
  font-size: 1.0rem;
  text-align: center;
  line-height: 1;
}
#clue-dir-bar {
  font-size: 1.45rem;
  font-weight: 700;
  flex-shrink: 0;
  line-height: 1;
}
#clue-dir-bar.dir-across { color: #5ab0e8; }
#clue-dir-bar.dir-down   { color: #6ad870; }
#clue-dir-bar.dir-up     { color: #e89850; }
#clue-dir-bar.dir-back   { color: #e870b0; }
#clue-text {
  flex: 1;
  font-size: 1.0rem;
  color: #dff0ff;
  line-height: 1.35;
}

.cell {
  width: var(--cell-size);
  height: var(--cell-size);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cell.blocked {
  background: transparent;
  cursor: default;
}

.cell:not(.blocked) {
  width: calc(var(--cell-size) - 6px);
  height: calc(var(--cell-size) - 6px);
  margin: 3px;
  background: rgba(255, 255, 255, 0.28);
  backdrop-filter: blur(2px) saturate(1.1);
  -webkit-backdrop-filter: blur(2px) saturate(1.1);
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: 6px;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.14),
    0 2px 6px rgba(0, 0, 0, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.55);
  cursor: pointer;
}

.cell.prefilled {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.45);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.1),
    0 1px 4px rgba(0, 0, 0, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.cell.selected-word:not(.blocked) {
  background: rgba(160, 215, 255, 0.38);
  border-color: rgba(140, 200, 255, 0.7);
}
.cell.selected-word.prefilled {
  background: rgba(160, 215, 255, 0.28);
  border-color: rgba(140, 200, 255, 0.55);
}

.cell.active-cell {
  background: rgba(90, 170, 240, 0.52) !important;
  border-color: rgba(80, 160, 240, 0.85) !important;
  box-shadow:
    0 2px 10px rgba(0, 0, 0, 0.25),
    inset 0 1px 0 rgba(200, 230, 255, 0.5) !important;
}

.cell.active-cell::after {
  content: attr(data-dir);
  position: absolute;
  bottom: 2px;
  right: 3px;
  font-size: calc(var(--cell-size) * 0.28);
  color: rgba(20, 60, 120, 0.5);
  pointer-events: none;
  line-height: 1;
}

@keyframes arrowDown  { 0%,100% { transform: translateY(0);    } 50% { transform: translateY(3px);  } }
@keyframes arrowUp    { 0%,100% { transform: translateY(0);    } 50% { transform: translateY(-3px); } }
@keyframes arrowRight { 0%,100% { transform: translateX(0);    } 50% { transform: translateX(3px);  } }
@keyframes arrowLeft  { 0%,100% { transform: translateX(0);    } 50% { transform: translateX(-3px); } }

.cell.active-cell[data-dir-name="down"]::after   { animation: arrowDown  0.9s ease-in-out infinite; }
.cell.active-cell[data-dir-name="up"]::after     { animation: arrowUp    0.9s ease-in-out infinite; }
.cell.active-cell[data-dir-name="across"]::after { animation: arrowRight 0.9s ease-in-out infinite; }
.cell.active-cell[data-dir-name="back"]::after   { animation: arrowLeft  0.9s ease-in-out infinite; }

.cell.correct,
.cell.correct.selected-word,
.cell.correct.active-cell {
  background: rgba(90, 200, 120, 0.38) !important;
  border-color: rgba(70, 185, 100, 0.65) !important;
  box-shadow:
    0 1px 6px rgba(0, 0, 0, 0.18),
    inset 0 1px 0 rgba(180, 255, 200, 0.4) !important;
}

.cell-letter {
  font-size: calc(var(--cell-size) * 0.5);
  font-weight: 800;
  text-transform: uppercase;
  pointer-events: none;
  user-select: none;
  line-height: 1;
  color: #1a2e0a;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.4);
}

.cell.prefilled .cell-letter {
  color: #3a2800;
}

.cell-number {
  position: absolute;
  top: 2px;
  left: 3px;
  font-size: calc(var(--cell-size) * 0.22);
  line-height: 1;
  color: rgba(20, 40, 10, 0.65);
  pointer-events: none;
  font-weight: 700;
}

#clue-list-wrap {
  display: none;
}

#clue-list-wrap::-webkit-scrollbar { width: 4px; }
#clue-list-wrap::-webkit-scrollbar-track { background: transparent; }
#clue-list-wrap::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }

#clue-list { display: flex; flex-direction: column; }

.clue-item {
  font-size: 0.9rem;
  padding: 8px 18px 8px 5px;
  cursor: pointer;
  display: flex;
  gap: 8px;
  align-items: baseline;
  color: #b8ac68;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  transition: background 0.12s, color 0.12s;
}
.clue-item:last-child { border-bottom: none; }
.clue-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #d4c880;
}
.clue-item.active {
  background: rgba(50, 130, 240, 0.18);
  color: #e8f4ff;
  font-weight: 600;
}
.clue-item.solved {
  color: #3a4a3c;
  text-decoration: line-through;
}

.clue-num {
  font-weight: 700;
  min-width: 20px;
  color: #c8b870;
  flex-shrink: 0;
  font-size: 0.78rem;
  text-align: right;
}
.clue-item.active .clue-num { color: #e8d580; }

.clue-item-theme {
  margin-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 10px;
}
.clue-item-theme .clue-num { color: #d4a84b; }

.clue-dir {
  font-size: 0.8rem;
  flex-shrink: 0;
  font-weight: 700;
}

.clue-dir.dir-across { color: #5ab0e8; }
.clue-dir.dir-down   { color: #6ad870; }
.clue-dir.dir-up     { color: #e89850; }
.clue-dir.dir-back   { color: #e870b0; }

#keyboard {
  display: none;
  padding: 6px 4px 10px;
  background: rgba(0, 0, 0, 0.38);
  backdrop-filter: blur(16px) saturate(1.2);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  gap: 5px;
  flex-direction: column;
  flex-shrink: 0;
}
#keyboard.visible { display: flex; }

@media (hover: hover) and (pointer: fine) {
  #keyboard { display: none !important; }
}

.kb-row { display: flex; justify-content: center; gap: 4px; }

.kb-key {
  height: 42px;
  min-width: 30px;
  padding: 0 4px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.09);
  color: #e8d9a0;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255,255,255,0.08);
  flex: 1;
  max-width: 38px;
}
.kb-key.wide { max-width: 54px; }
.kb-key:active { background: rgba(255, 255, 255, 0.2); }

#screen-win {
  align-items: center;
  justify-content: safe center;
  overflow-y: auto;
  padding: 1rem;
}

.win-card {
  position: relative;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: 420px;
  padding: 28px 24px 24px;
  background: rgba(10, 16, 26, 0.86);
  backdrop-filter: blur(14px) saturate(1.3);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  border: 1px solid rgba(110, 170, 230, 0.5);
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.45);
  text-align: center;
}

#screen-win.active .win-card {
  animation: winRise 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes winRise {
  from { opacity: 0; transform: translateY(28px); }
  to   { opacity: 1; transform: translateY(0); }
}
.win-card h2 {
  font-family: 'Jersey 25', sans-serif;
  font-size: 2.6rem;
  color: #f0e4a8;
  letter-spacing: 0.05em;
  margin: 0;
  text-shadow: 0 0 16px rgba(240, 210, 80, 0.2), 0 1px 4px rgba(0, 0, 0, 0.5);
}
#win-sub {
  font-size: 0.85rem;
  color: rgba(240, 217, 160, 0.75);
  margin-top: -8px;
}
#win-sub:empty { display: none; }
#win-badge:empty { display: none; }
#win-rows {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
}
#win-rows:empty { display: none; }
.win-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 4px;
}
#btn-play-again {
  padding: 10px 28px;
  background: transparent;
  border: 1.5px solid rgba(110, 170, 230, 0.5);
  border-radius: 100px;
  color: #dbe7f5;
  font-size: 0.95rem;
  cursor: pointer;
  letter-spacing: 0.03em;
  transition: background 0.15s, border-color 0.15s;
}
#btn-play-again:hover {
  background: rgba(110, 170, 230, 0.12);
  border-color: rgba(150, 200, 245, 0.8);
}
.win-share {
  padding: 10px 28px;
  background: rgba(110, 170, 230, 0.9);
  border: 1.5px solid rgba(150, 200, 245, 0.9);
  border-radius: 100px;
  color: #0a101a;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.03em;
  transition: background 0.15s, border-color 0.15s;
}
.win-share:hover { background: rgba(150, 200, 245, 1); }
.win-share[hidden] { display: none; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translate(-50%, 16px);
  z-index: 60;
  padding: 10px 18px;
  background: rgba(10, 16, 26, 0.92);
  border: 1px solid rgba(110, 170, 230, 0.5);
  border-radius: 100px;
  color: #dbe7f5;
  font-size: 0.9rem;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
#btn-win-close {
  position: absolute;
  top: 14px;
  right: 14px;
  font-size: 1.1rem;
  font-weight: 700;
  z-index: 2;
}

#win-badge { overflow: hidden; }
.badge-reveal {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px 16px 16px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  animation: badgeExpand 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes badgeExpand {
  from { max-height: 0;     opacity: 0; padding-top: 0; padding-bottom: 0; }
  to   { max-height: 340px; opacity: 1; }
}

.badge-reveal[data-rarity="uncommon"]  { background: radial-gradient(circle at 50% 28%, #3c8351, #123019 80%); box-shadow: inset 0 0 46px rgba(120,255,160,0.12); }
.badge-reveal[data-rarity="rare"]      { background: radial-gradient(circle at 50% 28%, #bd851d, #3a2604 80%); box-shadow: inset 0 0 46px rgba(255,200,90,0.14); }
.badge-reveal[data-rarity="epic"]      { background: radial-gradient(circle at 50% 28%, #2b569d, #081428 80%); box-shadow: inset 0 0 48px rgba(90,150,255,0.16); }
.badge-reveal[data-rarity="legendary"] { background: radial-gradient(circle at 50% 28%, #5e37a6, #170e2c 80%); box-shadow: inset 0 0 52px rgba(180,120,255,0.20); }

.badge-coin-stage { width: 138px; height: 138px; }
.badge-coin { position: relative; width: 100%; height: 100%; }

.badge-coin-px  { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; }

.badge-coin-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; transform-origin: center; }

.badge-coin-name   { font-family: system-ui, -apple-system, 'Segoe UI', sans-serif; font-size: 11px; font-weight: 700; letter-spacing: 0.4px; }
.badge-coin-date   { font-family: system-ui, -apple-system, 'Segoe UI', sans-serif; font-size: 8px; font-weight: 700; letter-spacing: 1px; fill: rgba(255, 255, 255, 0.60);}
[data-metal="bronze"] .badge-coin-date {fill: #e6ac64;}
[data-metal="silver"] .badge-coin-date {fill: #e9edf1;}
[data-metal="gold"]   .badge-coin-date {fill: #f4d968;}
.badge-coin-center { font-family: 'Jersey 25', sans-serif; }
.badge-reveal .badge-coin-name, .badge-reveal .badge-coin-center { fill: rgba(42, 27, 8, 0.9); }
.badge-reveal[data-metal="silver"] .badge-coin-name,
.badge-reveal[data-metal="silver"] .badge-coin-center { fill: rgba(36, 44, 54, 0.9); }

.badge-rarity { font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.18em; font-weight: 700; margin-top: 2px; }
.badge-reveal[data-rarity="uncommon"]  .badge-rarity { color: #9fe6b4; }
.badge-reveal[data-rarity="rare"]      .badge-rarity { color: #f4cf7e; }
.badge-reveal[data-rarity="epic"]      .badge-rarity { color: #93c2ff; }
.badge-reveal[data-rarity="legendary"] .badge-rarity { color: #cba6ff; }

.badge-desc {
  font-family: 'Jersey 25', sans-serif; font-size: 1.2rem; color: #fff;
  letter-spacing: 0.03em; text-align: center; line-height: 1.15;
  text-shadow: 0 1px 6px rgba(0,0,0,0.5);
}

#screen-stats {
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.stats-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: 420px;
  padding: 28px 24px 24px;
  background: rgba(10, 16, 26, 0.86);
  backdrop-filter: blur(14px) saturate(1.3);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  border: 1px solid rgba(110, 170, 230, 0.5);
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.45);
}
#btn-stats-close {
  position: absolute;
  top: 14px;
  right: 14px;
  font-size: 1.1rem;
  font-weight: 700;
}
.stats-card h2 {
  font-family: 'Jersey 25', sans-serif;
  font-size: 2rem;
  color: #f0e4a8;
  letter-spacing: 0.05em;
  text-shadow: 0 0 16px rgba(240, 210, 80, 0.2), 0 1px 4px rgba(0,0,0,0.5);
}
#stats-date {
  font-size: 0.7rem;
  color: rgba(240, 217, 160, 0.65);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-top: -12px;
}
#stats-rows {
  position:relative;
  padding:0.5rem 0 0;
  left:-1rem;
  width:calc(100% + 2rem);
}
.stats-row {
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.04);
  margin:0 0 0.5rem
}
.stats-row[data-diff="easy"]   { border-color: rgba(90,  200, 120, 0.2); }
.stats-row[data-diff="medium"] { border-color: rgba(200, 180,  80, 0.2); }
.stats-row[data-diff="hard"]   { border-color: rgba(220,  80,  80, 0.2); }

.stats-row-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.stats-diff {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
}
.stats-row[data-diff="easy"]   .stats-diff { color: #7aca8a; }
.stats-row[data-diff="medium"] .stats-diff { color: #c8b870; }
.stats-row[data-diff="hard"]   .stats-diff { color: #f08a8a; }

.stats-word {
  font-family: 'Jersey 25', sans-serif;
  font-size: 1.3rem;
  color: #e8d9a0;
  letter-spacing: 0.04em;
}

.stats-row-body {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}
.stats-stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.stats-stat-label {
  font-size: 0.62rem;
  color: rgba(255, 255, 255, 0.4);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.stats-stat-value {
  font-size: 0.85rem;
  color: #f0ede6;
  font-weight: 600;
}

#screen-profile {
  align-items: center;

  justify-content: safe center;
  overflow-y: auto;
  padding: 1rem;
}
.profile-card {
  flex-shrink: 0;
  gap: 12px;
}
#screen-profile.active .profile-card {
  animation: winRise 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}
#btn-profile-close {
  position: absolute;
  top: 14px;
  right: 14px;
  font-size: 1.1rem;
  font-weight: 700;
  z-index: 2;
}

#profile-main, #profile-legal {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#profile-main[hidden], #profile-legal[hidden] { display: none; }
.profile-card h2 {
  font-family: 'Jersey 25', sans-serif;
  font-size: 2rem;
  color: #f0e4a8;
  letter-spacing: 0.05em;
  text-shadow: 0 0 16px rgba(240, 210, 80, 0.2), 0 1px 4px rgba(0,0,0,0.5);
  margin: 0;
}

.accordion { display: flex; flex-direction: column; }
.acc-item {padding:0.75rem 0; border-top: 1px solid rgba(255, 255, 255, 0.1); }
.acc-item:last-child { border-bottom: 1px solid rgba(255, 255, 255, 0.1); }
.acc-head {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0;
  background: none;
  border: 0;
  cursor: pointer;
  color: #e8d9a0;
  font-size: 0.9rem;
  font-weight:bold;
  text-align: left;
  text-transform:uppercase;
}
.acc-title { display: inline-flex; align-items: center; gap: 8px; }
.acc-count {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #cddff0;
  background: rgba(110, 170, 230, 0.22);
  border: 1px solid rgba(110, 170, 230, 0.4);
  border-radius: 100px;
  padding: 1px 8px;
  line-height: 1.4;
}
.acc-count:empty { display: none; }
.acc-chevron {
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.55);
  transition: transform 0.2s ease;
}
.acc-item.open .acc-chevron { transform: rotate(180deg); }
.acc-body { padding: 2px 2px 16px; }
.acc-item:not(.open) .acc-body { display: none; }
.acc-note {
  font-size: 0.82rem;
  line-height: 1.4;
  color: rgba(220, 231, 245, 0.85);
  margin: 1rem 0 12px;
}
.acc-note b { color: #f0e4a8; }

.ach-grid {
  display: grid;

  grid-template-columns: repeat(6, minmax(0, 1fr));

  grid-auto-flow: row;
  gap: 0.6rem;
  align-items: start;
  margin: 1rem 0 0;
}
.ach-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.ach-slot .badge-reveal {
  background: none !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  margin: 0 !important;
  animation: none !important;
  max-height: none !important;
  overflow: visible !important;
  width: 100%;
}

.ach-slot .badge-coin-stage {
  width: 100%;
  height: auto;
  max-width: 96px;
  aspect-ratio: 1;
  margin: 0 auto;
  border-radius: 50%;
  box-shadow: 0 0 0 2.5px var(--ring, rgba(255, 255, 255, 0.2));
}
.ach-slot .badge-reveal[data-rarity="uncommon"]  { --ring: #57c07a; }
.ach-slot .badge-reveal[data-rarity="rare"]      { --ring: #f0b43c; }
.ach-slot .badge-reveal[data-rarity="epic"]      { --ring: #5b91e6; }
.ach-slot .badge-reveal[data-rarity="legendary"] { --ring: #b07cff; }

.ach-slot:not(.ach-blank) { cursor: pointer; }

.ach-slot.expanded {
  grid-column: span 3;
  grid-row: span 3;
  aspect-ratio: 1;
  justify-content: center;
  gap: 5px;
  padding: 8px;
  border-radius: 16px;
  overflow: hidden;
}
.ach-slot.expanded[data-rarity="uncommon"]  { background: radial-gradient(circle at 50% 30%, #3c8351, #123019 82%); }
.ach-slot.expanded[data-rarity="rare"]      { background: radial-gradient(circle at 50% 30%, #bd851d, #3a2604 82%); }
.ach-slot.expanded[data-rarity="epic"]      { background: radial-gradient(circle at 50% 30%, #2b569d, #081428 82%); }
.ach-slot.expanded[data-rarity="legendary"] { background: radial-gradient(circle at 50% 30%, #5e37a6, #170e2c 82%); }

.ach-slot.expanded .badge-coin-stage {
  width: 67%;
  max-width: 150px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
}

.ach-rarity {
  display: none;
  font-size: 0.55rem;
  font-weight: 700;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  text-align: center;
}
.ach-slot.expanded .ach-rarity { display: block; }
.ach-slot[data-rarity="uncommon"]  .ach-rarity { color: #9fe6b4; }
.ach-slot[data-rarity="rare"]      .ach-rarity { color: #f4cf7e; }
.ach-slot[data-rarity="epic"]      .ach-rarity { color: #93c2ff; }
.ach-slot[data-rarity="legendary"] .ach-rarity { color: #cba6ff; }
.ach-def {
  display: none;
  font-size: 0.66rem;
  line-height: 1.25;
  color: #fff;
  text-align: center;
}
.ach-slot.expanded .ach-def { display: block; }

.ach-blank { justify-content: flex-start; }
.ach-blank-circle {
  width: 100%;
  max-width: 96px;
  aspect-ratio: 1;
  margin: 0 auto;
  border-radius: 50%;
  border: 2px dashed rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.03);
  box-sizing: border-box;
}

.share-row { display: flex; gap: 8px; }
.share-input {
  flex: 1;
  min-width: 0;
  padding: 9px 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  color: #e8f0fb;
  font-size: 0.82rem;
  font-family: system-ui, -apple-system, sans-serif;
}
.share-btn {
  padding: 9px 18px;
  background: #f0e4a8;
  border: 1.5px solid #f0e4a8;
  border-radius: 8px;
  color: #1a2410;
  font-weight: 600;
  font-size:0.75rem;  text-transform:uppercase;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
}
.share-btn:hover { background: #f6ecba; border-color: #f6ecba; }
.share-stats {
  margin-top: 10px;
  font-size: 0.78rem;
  color: rgba(240, 217, 160, 0.8);
}
.share-stats:empty { display: none; }
.share-stats-row {margin:1.5rem 0 0; text-align:center; display:block;}

.pref-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 0;
  cursor: pointer;
}
.pref-toggle + .pref-toggle { border-top: 1px solid rgba(255, 255, 255, 0.08); }
.pref-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.pref-text b { font-size: 0.9rem; color: #f0ede6; font-weight: 600; }
.pref-text small { font-size: 0.72rem; color: rgba(255, 255, 255, 0.5); line-height: 1.3; }

.pref-toggle input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  width: 42px;
  height: 24px;
  flex-shrink: 0;
  border-radius: 100px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.2);
  cursor: pointer;
  transition: background 0.18s;
}
.pref-toggle input[type="checkbox"]::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #e8e2d2;
  transition: transform 0.18s;
}
.pref-toggle input[type="checkbox"]:checked {
  background: rgba(110, 170, 230, 0.9);
  border-color: rgba(150, 200, 245, 0.9);
}
.pref-toggle input[type="checkbox"]:checked::after { transform: translateX(18px); }

#screen-profile #stats-date { margin: 6px 0 12px; }

.notif-dot {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #e0453a;
  box-shadow: 0 0 6px rgba(224, 69, 58, 0.75);
}
.notif-dot[hidden] { display: none; }

.btn {
  padding: 11px 28px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(0, 0, 0, 0.4);
  color: #e8d9a0;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: background 0.15s;
}
.btn:hover { background: rgba(0, 0, 0, 0.58); }

#copyright { padding-top: 8px;}
#copyright p {text-align:center; font-size:11px; color:#e8d9a0;}
#copyright p a {display:inline-block; margin:0 0.125rem; color:#e8d9a0; font-weight:500; cursor: pointer;}
#copyright p a:hover {color: #f6ecba;}

.legal-back-btn {
  align-self: flex-start;
  background: none;
  border: 0;
  padding: 0;
  color: rgba(240, 217, 160, 0.75);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
}
.legal-back-btn:hover { color: #f0e4a8; }
#legal-title { font-size: 1.7rem; }
.legal-body {
  font-size: 0.82rem;
  line-height: 1.55;
  color: rgba(240, 237, 230, 0.85);
}
.legal-body p { margin: 0 0 10px; }
.legal-body ul { margin: 0 0 10px; padding-left: 1.2em; }
.legal-body p:last-child, .legal-body ul:last-child { margin-bottom: 0; }
.legal-body li { margin-bottom: 4px; }
.legal-body strong { color: #f0e4a8; font-weight: 700; }
.legal-body a { color:#e8d9a0; font-weight:500; text-decoration: underline; text-underline-offset: 2px; }
.legal-body a:hover { color: #f6ecba; }
.legal-credits { list-style: none; padding-left: 0; display: flex; flex-direction: column; gap: 10px; }
.legal-updated { font-size: 0.68rem; color: rgba(255, 255, 255, 0.4); margin-top: 2px; }

.panel-hidden {
  opacity: 0 !important;
  pointer-events: none !important;
}

@keyframes panelReveal {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0);    }
}
.panel-reveal {
  animation: panelReveal 0.45s ease forwards;
}

.cell.cell-enter {
  opacity: 0 !important;
  transform: translateY(8px) !important;
  transition: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

@keyframes cellPop {
  0%   { opacity: 0; transform: scale(0.4)  translateY(4px);  }
  60%  { opacity: 1; transform: scale(1.08) translateY(-1px); }
  100% { opacity: 1; transform: scale(1)    translateY(0);    }
}
.cell.cell-pop {
  animation: cellPop 0.22s cubic-bezier(0.34, 1.56, 0.64, 1) forwards !important;
}

@keyframes cellReveal {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0);   }
}
.cell.cell-reveal {
  animation: cellReveal 0.4s ease forwards !important;
}

@media (min-width: 800px) and (hover: hover) and (pointer: fine) {

  #screen-home { max-width: 860px; padding: calc(3 * 48px) 32px 24px; justify-content: flex-start; }
  #puzzle-tiles { flex-direction: row; gap: 16px; }
  .puzzle-tile { flex: 1; }
  .tile-word { font-size: 2.6rem; }
  #home-date { font-size: 0.8rem; }

  #game-layout { flex-direction: row; align-items: stretch; }
  #game-area { flex: 1; }

  #clue-panel {
    position: fixed;
    max-width: 420px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.13);
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(18px) saturate(1.3);
    -webkit-backdrop-filter: blur(18px) saturate(1.3);
    box-shadow:
      0 4px 24px rgba(0, 0, 0, 0.38),
      inset 0 1px 0 rgba(255, 255, 255, 0.08);
    border-top: 1px solid rgba(255, 255, 255, 0.13);
  }

  #clue-panel-header {
    display: flex;
    padding: 16px 18px 14px;
  }

  #clue-bar { display: none; }

  .clue-item.active .clue-num { color: #e8d580; }

  #clue-list-wrap {
    display: block;
    flex: 1;
    max-height: none;
    overflow-y: auto;
    padding: 6px 0 6px;
  }

  .wordmark { font-size: 2.4rem; }
  #hero.hero--compact .wordmark { font-size: 1.2rem; }

  .hero-actions { flex-direction: row; gap: 6px; }
  #hero { grid-template-columns: minmax(96px, 1fr) auto minmax(96px, 1fr); }
}

@media (pointer: coarse) {
  .cell:not(.blocked) {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  body.puzzle-loaded .cell:not(.blocked) {
    backdrop-filter: blur(2px) saturate(1.1);
    -webkit-backdrop-filter: blur(2px) saturate(1.1);
  }
}

@media (orientation: portrait) and (pointer: coarse) and (min-width: 600px) {

  #screen-home {
    max-width: 620px;
    justify-content: center;
    gap: 16px;
    padding: 0 24px 6vh;
  }
  #home-date { font-size: 0.95rem; }
  #puzzle-tiles { gap: 16px; }
  .puzzle-tile { padding: 26px 32px; border-radius: 18px; gap: 8px; }
  .tile-label { font-size: 0.78rem; }
  .tile-word { font-size: 3rem; }
  .tile-hint { font-size: 0.9rem; }
  .tile-status { top: 14px; right: 16px; font-size: 1.35rem; }
  .tile-status--won { font-size: 1.5rem; }

  #keyboard {
    gap: 8px;
    padding: 10px 8px 6vh;
  }
  .kb-row { gap: 6px; }
  .kb-key {
    height: 63px;
    min-width: 45px;
    padding: 0 6px;
    border-radius: 7px;
    font-size: 1.3rem;
    max-width: 57px;
  }
  .kb-key.wide { max-width: 81px; }

  #clue-bar { padding: 15px 20px; gap: 16px; }
  #clue-bar-meta { padding: 7px 14px; min-width: 56px; gap: 2px; }
  #clue-number { font-size: 1.3rem; }
  #clue-dir-bar { font-size: 1.9rem; }
  #clue-text { font-size: 1.3rem; }
}

@media (orientation: landscape) and (pointer: coarse) and (min-height: 600px) {

  #screen-home {
    max-width: 900px;
    justify-content: center;
    gap: 16px;
    padding: 0 32px 5vh;
  }
  #home-date { font-size: 0.9rem; }
  #puzzle-tiles { flex-direction: row; gap: 16px; }
  .puzzle-tile { flex: 1; padding: 22px; border-radius: 16px; }
  .tile-word { font-size: 2.6rem; }
  .tile-hint { font-size: 0.82rem; }

  #keyboard { padding: 8px 8px 4vh; }
}
