:root {
  font-family: ui-rounded, "Arial Rounded MT Bold", Nunito, system-ui, sans-serif;
  color: #0b2055;
  background: #d8f1ff;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100dvh; display: grid; place-items: center; padding: clamp(12px, 3vw, 36px); }
button, input, select { font: inherit; }
button { cursor: pointer; touch-action: manipulation; }
[hidden] { display: none !important; }
.game {
  width: min(100%, 1180px);
  padding: clamp(18px, 3.5vw, 44px);
  border-radius: 32px;
  background: #f8fcff;
  box-shadow: 0 12px 35px #0b205526;
}
h1 { margin: 0 0 clamp(18px, 3vw, 32px); text-align: center; font-size: clamp(2.1rem, 5vw, 4.5rem); line-height: 1.08; letter-spacing: -.045em; font-weight: 900; }
.play-layout { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(240px, .8fr); align-items: center; gap: clamp(18px, 4vw, 50px); }
.board {
  --rows: 4;
  --columns: 4;
  width: 100%;
  max-width: 630px;
  aspect-ratio: var(--columns) / var(--rows);
  display: grid;
  grid-template-columns: repeat(var(--columns), minmax(0, 1fr));
  grid-template-rows: repeat(var(--rows), minmax(0, 1fr));
  gap: clamp(5px, 1vw, 12px);
}
.tile {
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: clamp(9px, 1.7vw, 22px);
  background: #1b315f;
  color: white;
  font-size: clamp(1.5rem, 5vw, 4.5rem);
  font-weight: 900;
  box-shadow: 0 5px 0 #102348, 0 9px 14px #13295526;
  transition: transform .15s ease, background-color .15s ease, box-shadow .15s ease;
}
.tile:not(:disabled):hover { transform: translateY(-3px); }
.tile:not(:disabled):active { transform: translateY(2px); box-shadow: 0 2px 0 #102348; }
.tile:focus-visible, .new-game:focus-visible, .size-fields input:focus-visible, .mode-field select:focus-visible, .account-history button:focus-visible, .account-history a:focus-visible { outline: 4px solid #ffb800; outline-offset: 3px; }
.tile.revealed, .tile.matched { background: var(--tile-color); color: transparent; box-shadow: 0 5px 0 #0b205533, 0 9px 14px #13295520; }
.tile.matched { cursor: default; outline: 4px solid white; outline-offset: -7px; }
.tile:disabled { opacity: 1; }
.board[data-mode="letters"] { --tile-color: #e5d5ff; }
.board[data-mode="numbers"] { --tile-color: #c7f1df; }
.board[data-mode="objects"] { --tile-color: #fff4d8; }
.board:not([data-mode="colors"]) .tile.revealed {
  color: #0b2055;
  font-size: clamp(1rem, calc(67 * min(100vw, 630px) / 100 / var(--columns)), 16rem);
  line-height: 1;
}
.board[data-mode="numbers"] .tile.two-digit.revealed {
  font-size: clamp(1rem, calc(60 * min(100vw, 630px) / 100 / var(--columns)), 16rem);
}
.board[data-mode="objects"] .tile.revealed {
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
  font-size: clamp(1rem, calc(60 * min(100vw, 630px) / 100 / var(--columns)), 16rem);
}
.game-side { display: flex; flex-direction: column; align-items: stretch; gap: 16px; text-align: center; }
.progress { margin: 0; padding: 13px 12px; border-radius: 999px; background: #bde4ff; font-size: clamp(1.2rem, 2.6vw, 2.2rem); font-weight: 900; }
.game-stats { display: flex; justify-content: center; gap: clamp(18px, 3vw, 42px); font-size: 1.05rem; }
.game-stats span { display: flex; flex-direction: column; gap: 3px; color: #415b82; }
.game-stats strong { color: #0b2055; font-size: 1.35rem; }
.message { margin: 0; min-height: 2.4em; display: grid; place-items: center; font-size: clamp(1.25rem, 2.5vw, 2.1rem); line-height: 1.2; font-weight: 900; }
.setup { padding: 12px; border: 2px solid #d7e9f8; border-radius: 18px; }
.mode-field {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 12px;
  font-weight: 900;
}
.mode-field select {
  min-height: 44px;
  padding: 4px 10px;
  border: 2px solid #b8d8f2;
  border-radius: 10px;
  background: white;
  color: #0b2055;
}
.sound-field { display: flex; align-items: center; justify-content: center; gap: 9px; min-height: 44px; margin-bottom: 10px; font-weight: 800; cursor: pointer; }
.sound-field input { width: 22px; height: 22px; margin: 0; accent-color: #1168df; cursor: pointer; }
.sound-field:has(input:disabled) { opacity: .6; cursor: default; }
.sound-help { margin: -4px 0 12px; color: #415b82; font-size: .8rem; line-height: 1.35; text-align: left; }
.sound-help summary { color: #0756d3; font-weight: 800; text-align: center; cursor: pointer; }
.sound-help p { margin: 8px 0 5px; }
.sound-help ul { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 3px 10px; margin: 0; padding-left: 22px; }
.sound-help code { overflow-wrap: anywhere; color: #0b2055; font-size: .75rem; }
.setup-title { margin: 0 0 8px; font-size: 1rem; font-weight: 900; }
.size-fields { display: flex; align-items: end; justify-content: center; gap: 10px; }
.size-fields label { display: flex; flex-direction: column; gap: 3px; color: #415b82; font-size: .85rem; font-weight: 750; }
.size-fields input { width: 80px; height: 44px; padding: 4px 8px; border: 2px solid #b8d8f2; border-radius: 10px; background: white; color: #0b2055; text-align: center; font-size: 1.2rem; font-weight: 900; }
.size-fields > span { padding-bottom: 8px; font-size: 1.5rem; font-weight: 900; }
.size-error { margin: 8px 0 0; color: #a33232; font-size: .85rem; font-weight: 750; }
.new-game { min-height: 60px; padding: 14px 20px; border: 0; border-radius: 18px; background: #0861ed; color: white; font-size: clamp(1.2rem, 2.5vw, 2rem); font-weight: 900; box-shadow: 0 6px 0 #0048b8, 0 12px 16px #0b205526; }
.new-game:hover { background: #0756d3; }
.new-game:active { transform: translateY(3px); box-shadow: 0 3px 0 #0048b8; }
.session-score { display: flex; flex-direction: column; gap: 3px; padding: 9px; border-radius: 13px; background: #eaf5ff; color: #415b82; font-size: .94rem; }
.session-score strong { color: #0b2055; }
.account-history { min-height: 28px; font-size: .85rem; line-height: 1.4; }
.account-history p { margin: 0 0 5px; }
.account-history a, .account-history button { color: #0756d3; font-weight: 800; }
.account-history button { padding: 6px 10px; border: 1px solid #bdd6f1; border-radius: 8px; background: white; }
.history-panel { margin-top: 22px; padding-top: 16px; border-top: 2px solid #d7e9f8; }
.history-panel h2 { margin: 0 0 5px; font-size: 1.3rem; }
.history-panel p { margin: 0 0 10px; color: #415b82; }
.history-panel ol { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 7px; margin: 0; padding: 0; list-style: none; }
.history-panel li { padding: 10px; border-radius: 9px; background: #eaf5ff; font-size: .87rem; }
@media (max-width: 680px) {
  body { display: block; padding: 10px; background: #f8fcff; }
  .game { padding: 8px 4px 24px; border-radius: 0; box-shadow: none; }
  h1 { margin: 8px 0 18px; font-size: clamp(2rem, 9vw, 3.2rem); }
  .play-layout { display: flex; flex-direction: column; gap: 20px; }
  .board { width: min(100%, 520px); gap: clamp(5px, 1.5vw, 10px); }
  .tile { border-radius: clamp(8px, 3vw, 18px); font-size: clamp(1.3rem, 9vw, 3rem); }
  .game-side { width: min(100%, 520px); gap: 12px; }
  .progress { padding: 9px 12px; font-size: 1.35rem; }
  .game-stats { gap: 30px; }
  .message { min-height: 1.4em; font-size: 1.35rem; }
  .new-game { min-height: 56px; font-size: 1.35rem; border-radius: 16px; }
}
@media (prefers-reduced-motion: reduce) { .tile { transition: none; } }
