:root {
  --bg: #070b16;
  --text: #f4f7fb;
  --muted: #93a0b8;
  --accent: #7dd3fc;
  --highlight: #f5d76e;
  --button-bg: #f5d76e;
  --button-text: #1a1403;
  --card-bg: rgba(16, 24, 40, 0.72);
  --row-bg: rgba(255, 255, 255, 0.05);
  --line: rgba(255, 255, 255, 0.1);
  --input-bg: rgba(7, 11, 22, 0.55);
}

body.light-mode {
  --bg: #eef2f7;
  --text: #122033;
  --muted: #5b6b82;
  --accent: #2563eb;
  --highlight: #b45309;
  --button-bg: #1d4ed8;
  --button-text: #ffffff;
  --card-bg: rgba(255, 255, 255, 0.82);
  --row-bg: rgba(15, 23, 42, 0.04);
  --line: rgba(15, 23, 42, 0.08);
  --input-bg: #ffffff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Noto Sans Thai", "Noto Sans Lao", "Noto Sans Myanmar", "Noto Sans", sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 28px 16px 48px;
  background:
    radial-gradient(900px 420px at 12% -10%, rgba(56, 189, 248, 0.18), transparent 55%),
    radial-gradient(700px 380px at 100% 8%, rgba(245, 215, 110, 0.12), transparent 50%),
    var(--bg);
  transition: background 0.3s, color 0.3s;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.35;
  background-image: linear-gradient(rgba(255,255,255,0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.035) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: radial-gradient(circle at center, black 35%, transparent 85%);
}

body.light-mode::before { opacity: 0.18; }

.theme-toggle {
  position: fixed;
  top: 16px;
  right: 16px;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: var(--card-bg);
  color: var(--accent);
  border: 1px solid var(--line);
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  backdrop-filter: blur(16px);
  z-index: 999;
}

.app-container {
  position: relative;
  max-width: 480px;
  width: 100%;
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: 28px;
  backdrop-filter: blur(22px);
  padding: 28px 20px 32px;
}

.brand {
  margin: 0 0 6px;
  text-align: center;
  font-size: 11px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

h1 {
  font-size: 22px;
  margin: 0 0 14px;
  text-align: center;
  font-weight: 700;
  letter-spacing: -0.02em;
}

#countdown {
  display: block;
  width: fit-content;
  margin: 0 auto 18px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--row-bg);
  border: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}

.hero {
  text-align: center;
  background: linear-gradient(180deg, rgba(245, 215, 110, 0.08), transparent 70%), var(--row-bg);
  border-radius: 22px;
  padding: 22px 14px 18px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
}

.hero-label {
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}

.hero-digits {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin: 14px 0 12px;
}

.digit {
  width: 42px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: rgba(7, 11, 22, 0.45);
  border: 1px solid rgba(245, 215, 110, 0.28);
  color: var(--highlight);
  font-family: "IBM Plex Mono", monospace;
  font-size: 28px;
  font-weight: 700;
  animation: rise 0.35s ease both;
}

.digit:nth-child(2) { animation-delay: 0.04s; }
.digit:nth-child(3) { animation-delay: 0.08s; }
.digit:nth-child(4) { animation-delay: 0.12s; }
.digit:nth-child(5) { animation-delay: 0.16s; }
.digit:nth-child(6) { animation-delay: 0.2s; }

body.light-mode .digit {
  background: #fff;
  border-color: rgba(180, 83, 9, 0.2);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.hero-prize {
  font-size: 13px;
  color: var(--muted);
}

.hero-date {
  font-size: 13px;
  margin-top: 8px;
  font-weight: 600;
}

.near-row {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 0 0 12px;
}

.chip {
  background: var(--row-bg);
  border: 1px solid var(--line);
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 12px;
  color: var(--muted);
}

.chip strong {
  color: var(--highlight);
  font-family: "IBM Plex Mono", monospace;
  margin-left: 4px;
}

.mini-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 18px;
}

.mini-card {
  background: var(--row-bg);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 6px;
  text-align: center;
}

.mini-card .label {
  font-size: 11px;
  color: var(--muted);
  display: block;
  margin-bottom: 8px;
}

.mini-card .nums {
  font-family: "IBM Plex Mono", monospace;
  font-weight: 700;
  color: var(--highlight);
  font-size: 13px;
}

.check-card {
  background: var(--row-bg);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 8px;
}

.check-label {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
}

input[type="text"] {
  width: 100%;
  padding: 13px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  margin-bottom: 10px;
  font-size: 16px;
  background: var(--input-bg);
  color: var(--text);
  font-family: "IBM Plex Mono", monospace;
  letter-spacing: 0.12em;
  outline: none;
}

input[type="text"]:focus {
  border-color: var(--accent);
}

button {
  width: 100%;
  padding: 13px;
  background: var(--button-bg);
  border: none;
  color: var(--button-text);
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}

button:hover { filter: brightness(1.05); }

#check-result {
  text-align: center;
  margin: 10px 0 0;
  font-weight: 600;
  min-height: 1.4em;
  white-space: pre-line;
  font-size: 14px;
}

.fold-section { margin-top: 22px; }

.fold-toggle {
  background: var(--row-bg);
  border: 1px solid var(--line);
  color: var(--text);
  font-weight: 600;
  text-align: left;
  width: 100%;
  margin: 8px 0 0;
  cursor: pointer;
  padding: 12px 16px;
  border-radius: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.fold-toggle::after {
  content: "";
  width: 7px;
  height: 7px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  margin-top: -3px;
}

.fold-content {
  background: var(--row-bg);
  border: 1px solid var(--line);
  border-top: none;
  padding: 12px;
  border-radius: 0 0 14px 14px;
  display: none;
  font-size: 13px;
  font-family: "IBM Plex Mono", monospace;
  column-count: 2;
}

.section-title {
  font-size: 15px;
  margin: 28px 0 12px;
  font-weight: 700;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  background: var(--row-bg);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 12px 14px;
  border-radius: 14px;
  cursor: pointer;
  font-weight: 500;
  text-align: left;
}

.history-item.active {
  border-color: var(--highlight);
  background: rgba(245, 215, 110, 0.08);
}

.history-item .meta {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.history-item .date { font-size: 13px; }

.history-item .back2 {
  font-size: 11px;
  color: var(--muted);
}

.history-item .first {
  color: var(--highlight);
  font-family: "IBM Plex Mono", monospace;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.about {
  margin-top: 36px;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.7;
}

.about h2 {
  color: var(--text);
  font-size: 16px;
  margin: 0 0 10px;
}

.footer {
  text-align: center;
  margin-top: 28px;
  font-size: 12px;
  color: var(--muted);
  max-width: 480px;
  line-height: 1.7;
}

.footer a {
  color: var(--accent);
  text-decoration: none;
}

.lang-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 10px 0 4px;
}

.lang-nav a {
  margin: 0;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--row-bg);
  font-size: 12px;
  color: var(--text);
}

.lang-nav a:hover {
  border-color: var(--accent);
  color: var(--accent);
}

@media (max-width: 420px) {
  .digit {
    width: 36px;
    height: 48px;
    font-size: 24px;
  }
}
