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

:root {
  --ink: #111111;
  --yellow: #FFE26A;
  --pale-yellow: #FFF2BC;
  --muted: #686868;
  --line: #e7e7e7;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  background: #fff;
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

button { font: inherit; }
button:focus-visible { outline: 3px solid #8460d9; outline-offset: 4px; }

.navbar {
  width: 100%;
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 24px;
  flex-shrink: 0;
}
.logo { display: flex; align-items: center; min-width: 0; }
.logo a { display: flex; align-items: center; }
.logo img { display: block; width: 180px; max-width: 100%; height: auto; }
.navbar-actions { display: flex; align-items: center; gap: 8px; }
.how-to-play-nav {
  min-height: 36px; padding: 9px 12px; border: 1px solid var(--ink);
  border-radius: 50px; background: var(--yellow); color: var(--ink);
  font-size: 10px; font-weight: 700; letter-spacing: 1px; white-space: nowrap;
  cursor: pointer; transition: background .2s, color .2s, transform .2s;
}
.how-to-play-nav:hover { background: var(--ink); color: #fff; }
.how-to-play-nav:active { transform: scale(.97); }

.game {
  width: 100%; max-width: 470px; flex: 1; margin: 0 auto;
  padding: 30px 25px 45px; display: flex; align-items: center; justify-content: center;
}
.screen { display: none; width: 100%; text-align: center; animation: fadeIn .28s ease; }
.screen.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.label { margin-bottom: 18px; font-size: 11px; font-weight: 700; letter-spacing: 2.5px; }
h1 { margin-bottom: 16px; font-size: clamp(30px, 7vw, 40px); line-height: 1.12; letter-spacing: -1px; }
.splash-content { width: 100%; }
.splash-content .label { margin-bottom: 20px; }
.splash-description { max-width: 345px; margin: 0 auto 26px; font-size: 15px; line-height: 1.65; color: #424242; }
.daily-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0 0 20px; }
.daily-summary > div { display: flex; flex-direction: column; gap: 7px; padding: 15px 5px; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.daily-summary strong { font-size: 19px; }
.daily-summary span { font-size: 10px; color: var(--muted); }
.daily-status { margin: 0 0 12px; color: #555; font-size: 12px; line-height: 1.5; }
.primary-button {
  width: 100%; min-height: 54px; padding: 16px 18px; border: 1px solid var(--ink);
  border-radius: 50px; background: var(--yellow); color: var(--ink);
  font-size: 12px; font-weight: 800; letter-spacing: 1.5px; cursor: pointer;
  transition: transform .18s, background .18s;
}
.primary-button:hover { background: #ffda3e; transform: translateY(-2px); }
.primary-button:active { transform: scale(.98); }
.small-note { margin-top: 15px; font-size: 11px; line-height: 1.5; color: var(--muted); }

.round-heading { display: flex; flex-direction: column; gap: 0; align-items: center; }
.round-heading .label { margin-bottom: 10px; }
.round-label { display: inline-block; margin-bottom: 20px; padding: 7px 11px; border-radius: 30px; background: var(--pale-yellow); font-size: 10px; font-weight: 700; letter-spacing: 1.2px; }
.code-display { padding: 18px 0; font-size: clamp(36px, 10vw, 54px); font-weight: 700; letter-spacing: 8px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.instruction { margin: 4px auto 0; max-width: 300px; font-size: 14px; line-height: 1.5; color: var(--muted); }
.countdown { width: 66px; height: 66px; display: flex; align-items: center; justify-content: center; margin: 32px auto 18px; border: 2px solid var(--yellow); border-radius: 50%; background: var(--pale-yellow); }
#countdownNumber { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }
.progress-container { width: 82%; height: 6px; margin: 0 auto; overflow: hidden; border-radius: 10px; background: #eee; }
.progress-bar { width: 100%; height: 100%; background: var(--yellow); transform-origin: left center; transform: scaleX(1); will-change: transform; }

.entered-code { min-height: 26px; display: flex; justify-content: center; align-items: center; gap: 11px; flex-wrap: wrap; margin: 5px 0 14px; }
.entered-code span { width: 17px; height: 17px; border: 2px solid #a8a8a8; border-radius: 50%; transition: background .15s, border-color .15s; }
.entered-code span.filled { background: var(--ink); border-color: var(--ink); }
.feedback { min-height: 22px; margin-bottom: 14px; font-size: 13px; }
.feedback.error { color: #c22f2f; }
.feedback.success { color: #267544; }
.keypad { width: 100%; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 20px; }
.key { aspect-ratio: 1 / .78; display: flex; justify-content: center; align-items: center; border: 1px solid #ececec; border-radius: 16px; background: #f7f7f7; color: var(--ink); cursor: pointer; transition: background .15s, transform .15s; }
.key strong { font-size: 27px; font-weight: 500; }
.key:hover { background: var(--pale-yellow); }
.key:active { transform: scale(.96); }
.delete-button { border: 0; background: transparent; font-size: 10px; font-weight: 700; letter-spacing: 1px; cursor: pointer; }
.delete-button:hover { color: #8b6500; }
.secondary-button { width: 100%; padding: 17px 10px 8px; border: 0; background: transparent; color: #555; font-size: 10px; font-weight: 700; letter-spacing: 1.4px; cursor: pointer; }
.secondary-button:hover { color: #000; text-decoration: underline; }
.keyboard-tip { margin-top: 17px; color: #777; font-size: 11px; line-height: 1.55; }
.keyboard-tip strong { color: #333; }

.result-icon, .final-icon { width: 70px; height: 70px; display: flex; justify-content: center; align-items: center; margin: 0 auto 22px; border-radius: 50%; font-size: 34px; font-weight: 500; }
.success-icon { background: #e5f6e9; color: #267544; }
.gave-up-icon { background: #fff0d8; color: #8a5700; }
.screen h1 { margin-bottom: 12px; }
.result-description { max-width: 320px; margin: 0 auto 22px; color: #555; font-size: 14px; line-height: 1.6; }
.result-code-wrap { margin: 22px 0; padding: 18px 12px; border-radius: 16px; background: #f7f7f7; }
.result-code-wrap > span { color: #777; font-size: 9px; font-weight: 700; letter-spacing: 2px; }
.correct-code { margin-top: 8px; font-size: 32px; font-weight: 700; letter-spacing: 7px; font-variant-numeric: tabular-nums; }
.round-progress-text { margin: 0 0 18px; font-size: 12px; color: #555; }
.final-icon { background: var(--pale-yellow); color: #6e5600; }
.final-score { display: flex; flex-direction: column; gap: 4px; margin: 24px 0 18px; }
.final-score strong { font-size: 52px; line-height: 1; }
.final-score span { color: #555; font-size: 12px; }
.final-round-marks { display: flex; justify-content: center; gap: 9px; margin: 20px 0 25px; }
.final-round-marks span { width: 34px; height: 34px; display: flex; justify-content: center; align-items: center; border-radius: 50%; background: #eee; font-size: 13px; font-weight: 700; }
.final-round-marks span.solved { background: #dff3e4; color: #267544; }
.final-round-marks span.gave-up { background: #fff0d8; color: #8a5700; }
.tomorrow-message { margin-bottom: 8px; font-size: 14px; font-weight: 700; }
.reset-countdown { margin-bottom: 22px; color: #777; font-size: 11px; }

.modal { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 18px; background: rgba(0,0,0,.48); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .2s, visibility .2s; }
.modal.active { opacity: 1; visibility: visible; pointer-events: auto; }
.modal-content { position: relative; width: 100%; max-width: 430px; max-height: 90vh; overflow-y: auto; padding: 30px 24px 24px; border-radius: 22px; background: #fff; box-shadow: 0 20px 70px rgba(0,0,0,.2); transform: translateY(10px); transition: transform .2s; }
.modal.active .modal-content { transform: translateY(0); }
.modal-close { position: absolute; top: 10px; right: 13px; width: 38px; height: 38px; border: 0; border-radius: 50%; background: transparent; font-size: 30px; cursor: pointer; }
.modal-label { margin-bottom: 10px; color: #777; font-size: 10px; font-weight: 700; letter-spacing: 2px; }
.modal-content h2 { margin-bottom: 9px; font-size: 29px; }
.modal-description { margin-bottom: 20px; color: #666; font-size: 13px; line-height: 1.5; }
.modal-instructions { display: flex; flex-direction: column; gap: 9px; }
.instruction-item { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 12px; background: #fff8d9; text-align: left; }
.instruction-number { width: 34px; min-width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--yellow); font-size: 10px; font-weight: 800; }
.instruction-item strong { display: block; margin-bottom: 4px; font-size: 12px; }
.instruction-item div span { display: block; color: #555; font-size: 11px; line-height: 1.45; }

/* =========================================
   SHARE RESULT BUTTON
========================================= */

.share-result-button {
    width: 100%;
    margin-top: 12px;
    padding: 16px;
    border: 1px solid #000;
    border-radius: 50px;
    background: #fff;
    color: #000;
    font-family: inherit;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 1.5px;
    cursor: pointer;
    transition:
        background 0.2s ease,
        color 0.2s ease,
        transform 0.2s ease;
}

.share-result-button:hover {
    background: #FFF2BC;
    transform: translateY(-2px);
}

.share-result-button:active {
    transform: scale(0.97);
}

.share-result-button:focus-visible {
    outline: 3px solid #FFE26A;
    outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
    .share-result-button {
        transition: none;
    }
}

@media (max-width: 768px) { .navbar { padding: 0 18px; } .logo img { width: 145px; } }
@media (max-width: 480px) {
  .navbar { min-height: 64px; padding: 0 12px; }
  .logo img { width: 110px; }
  .how-to-play-nav { min-height: 32px; padding: 8px 9px; font-size: 9px; letter-spacing: .5px; }
  .game { padding: 20px 18px 35px; }
  .daily-summary { gap: 6px; }
  .daily-summary > div { padding: 13px 3px; }
  .daily-summary strong { font-size: 17px; }
  .daily-summary span { font-size: 9px; }
  .keypad { gap: 8px; }
  .key { border-radius: 13px; }
  .key strong { font-size: 25px; }
  .code-display { letter-spacing: 5px; }
  .correct-code { letter-spacing: 5px; }
  .modal-content { padding: 28px 18px 20px; }
}
@media (max-height: 700px) {
  .navbar { min-height: 58px; }
  .game { padding-top: 15px; padding-bottom: 20px; }
  .splash-description { margin-bottom: 18px; }
  .daily-summary { margin-bottom: 13px; }
  .countdown { margin-top: 20px; }
  .keypad { gap: 7px; margin-bottom: 12px; }
  .key { aspect-ratio: 1 / .65; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}