:root {
  --ink: #17211d;
  --muted: #69716d;
  --cream: #f5f2eb;
  --paper: #fffdf8;
  --line: #dedbd2;
  --green: #195c45;
  --green-dark: #124633;
  --lime: #c8ef68;
  --red: #d95749;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 8%, rgba(200, 239, 104, .16), transparent 28rem),
    var(--cream);
  font-family: "DM Sans", "Noto Sans JP", sans-serif;
}

.adsbygoogle {
  margin-top: 24px;
}

button, kbd { font: inherit; }
button { color: inherit; }

.app-shell {
  width: min(1120px, calc(100% - 40px));
  margin: 0 auto;
}

.topbar {
  height: 84px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
  letter-spacing: -.02em;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--green);
}

.brand-mark svg {
  width: 22px;
  fill: none;
  stroke: var(--lime);
  stroke-width: 2;
  stroke-linecap: round;
}

.sound-button {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}

.sound-button svg {
  width: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sound-off { display: none; }
.sound-button[aria-pressed="false"] .sound-on { display: none; }
.sound-button[aria-pressed="false"] .sound-off { display: block; }

.hero {
  padding: 24px 0 12px;
  text-align: center;
}

.eyebrow {
  color: var(--green);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .22em;
}

.hero h1 {
  margin: 12px 0 10px;
  font-size: clamp(34px, 5vw, 56px);
  line-height: 1.2;
  letter-spacing: -.055em;
}

.hero p {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
}

.test-card {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: 24px;
  border: 1px solid rgba(23, 33, 29, .08);
  border-radius: 24px;
  background: rgba(255, 253, 248, .76);
  box-shadow: 0 18px 50px rgba(34, 48, 41, .07);
}

.progress-wrap { margin: 0 4px 20px; }
.progress-meta {
  display: flex;
  justify-content: space-between;
  margin-bottom: 9px;
  color: #7b817e;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .16em;
}
.progress-meta strong { color: var(--ink); letter-spacing: .04em; }
.progress-track {
  height: 4px;
  overflow: hidden;
  border-radius: 4px;
  background: #e6e3dc;
}
.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
  transition: width .35s ease;
}

.reaction-area {
  width: 100%;
  min-height: 320px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 16px;
  background: #ece9e1;
  cursor: default;
  transition: background .18s ease, color .18s ease, transform .12s ease;
}

.reaction-area.waiting {
  color: var(--paper);
  background: var(--green);
  cursor: pointer;
}

.reaction-area.ready {
  color: #112311;
  background: var(--lime);
  cursor: pointer;
}

.reaction-area.too-soon {
  color: white;
  background: var(--red);
  cursor: pointer;
}

.reaction-area:active:not(.idle) { transform: scale(.994); }

.pulse-icon {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  margin-bottom: 22px;
  border: 1px solid rgba(25, 92, 69, .22);
  border-radius: 50%;
  color: var(--green);
}
.pulse-icon svg {
  width: 34px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 1.6;
}
.waiting .pulse-icon, .ready .pulse-icon, .too-soon .pulse-icon {
  border-color: currentColor;
  color: inherit;
}
.waiting .pulse-icon { animation: breathe 1.2s ease-in-out infinite; }

@keyframes breathe {
  50% { transform: scale(1.08); opacity: .65; }
}

.reaction-title {
  font-size: clamp(24px, 4vw, 34px);
  font-weight: 700;
  letter-spacing: -.04em;
}
.reaction-copy {
  margin-top: 10px;
  color: #747b77;
  font-size: 14px;
}
.waiting .reaction-copy, .ready .reaction-copy, .too-soon .reaction-copy { color: inherit; opacity: .72; }
.reaction-time {
  margin-top: 4px;
  font-size: clamp(54px, 9vw, 78px);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -.06em;
}

.primary-button, .secondary-button, .dialog-submit {
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 700;
  transition: transform .15s ease, background .15s ease;
}
.primary-button {
  width: min(360px, calc(100% - 48px));
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin: 22px auto 0;
  color: white;
  background: var(--green);
  box-shadow: 0 9px 24px rgba(25, 92, 69, .18);
}
.primary-button:hover { background: var(--green-dark); transform: translateY(-1px); }
.primary-button svg {
  width: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}
.primary-button[hidden] { display: none; }

.hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 18px;
  color: #8a8f8c;
  font-size: 11px;
}
.hint .divider { width: 1px; height: 10px; background: var(--line); }
kbd {
  padding: 3px 8px;
  border: 1px solid #cfccc4;
  border-bottom-width: 2px;
  border-radius: 5px;
  color: #676d69;
  background: #f8f6f1;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .08em;
}

.results-panel {
  width: min(760px, 100%);
  margin: 24px auto 0;
  padding: 40px 24px;
  border-radius: 24px;
  color: white;
  background: var(--green);
  text-align: center;
}
.results-panel[hidden] { display: none; }
.results-panel > p {
  margin: 0 0 8px;
  color: var(--lime);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .18em;
}
.results-panel > strong { display: block; font-size: 64px; line-height: 1.1; letter-spacing: -.06em; }
.results-panel > strong small { font-size: 20px; letter-spacing: 0; }
.results-panel > span { display: block; margin-top: 8px; opacity: .75; font-size: 14px; }
.attempt-list {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 25px 0;
}
.attempt-list span {
  padding: 8px 11px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 8px;
  background: rgba(255,255,255,.07);
  font-size: 12px;
}
.secondary-button { padding: 13px 26px; color: var(--green); background: var(--lime); }
.secondary-button:hover { transform: translateY(-1px); background: #d5f783; }
.result-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
}
.share-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border: 1px solid rgba(255,255,255,.5);
  border-radius: 999px;
  color: white;
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  transition: background .15s ease, transform .15s ease;
}
.share-button:hover {
  background: rgba(255,255,255,.1);
  transform: translateY(-1px);
}
.share-button svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}
.text-button {
  border: 0;
  border-bottom: 1px solid rgba(255,255,255,.45);
  padding: 4px 0;
  color: white;
  background: transparent;
  cursor: pointer;
  font-size: 13px;
}
.text-button:hover { border-color: white; }

.ranking-panel {
  width: min(760px, 100%);
  margin: 24px auto 0;
  padding: 28px 32px 18px;
  border: 1px solid rgba(23, 33, 29, .08);
  border-radius: 24px;
  background: var(--paper);
  box-shadow: 0 18px 50px rgba(34, 48, 41, .05);
}
.ranking-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.ranking-heading span {
  color: var(--green);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .2em;
}
.ranking-heading h2 { margin: 3px 0 0; font-size: 24px; letter-spacing: -.04em; }
.ranking-heading button {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--green);
  background: transparent;
  cursor: pointer;
}
.ranking-heading button:hover { background: var(--cream); }
.ranking-heading button:disabled { opacity: .5; }
.ranking-heading svg {
  width: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.ranking-status { padding: 28px 0; color: var(--muted); text-align: center; font-size: 13px; }
.ranking-list { margin: 0; padding: 0; list-style: none; }
.ranking-row {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  align-items: center;
  min-height: 56px;
  border-bottom: 1px solid #ebe8e1;
}
.ranking-row:last-child { border-bottom: 0; }
.rank {
  color: #929792;
  font-size: 13px;
  font-weight: 700;
}
.ranking-row:nth-child(-n+3) .rank { color: var(--green); font-size: 16px; }
.ranking-name {
  overflow: hidden;
  font-size: 14px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ranking-score { font-size: 18px; font-weight: 700; letter-spacing: -.03em; }
.ranking-score small { color: var(--muted); font-size: 11px; font-weight: 500; }
.ranking-row.is-new {
  margin: 0 -14px;
  padding: 0 14px;
  border-radius: 10px;
  background: rgba(200, 239, 104, .23);
}

.name-dialog {
  width: min(430px, calc(100% - 28px));
  padding: 0;
  border: 0;
  border-radius: 22px;
  color: var(--ink);
  background: var(--paper);
  box-shadow: 0 24px 80px rgba(7, 25, 18, .3);
}
.name-dialog::backdrop { background: rgba(12, 28, 21, .6); backdrop-filter: blur(4px); }
.name-dialog form { position: relative; padding: 36px; }
.dialog-close {
  position: absolute;
  top: 16px;
  right: 18px;
  border: 0;
  color: #777e79;
  background: transparent;
  cursor: pointer;
  font-size: 25px;
  line-height: 1;
}
.dialog-eyebrow { color: var(--green); font-size: 9px; font-weight: 700; letter-spacing: .2em; }
.name-dialog h2 { margin: 7px 0 8px; font-size: 30px; letter-spacing: -.04em; }
.name-dialog form > p { margin: 0 0 26px; color: var(--muted); font-size: 13px; }
.name-dialog form > p strong { color: var(--green); }
.name-dialog label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 700;
}
.name-dialog label span { color: #969b97; font-weight: 400; }
.name-input-wrap { position: relative; }
.name-input-wrap input {
  width: 100%;
  height: 52px;
  border: 1px solid #cbc9c1;
  border-radius: 10px;
  outline: none;
  padding: 0 72px 0 14px;
  background: white;
  font: inherit;
}
.name-input-wrap input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(25, 92, 69, .1); }
.name-input-wrap span {
  position: absolute;
  top: 50%;
  right: 14px;
  color: #999e9a;
  transform: translateY(-50%);
  font-size: 11px;
}
.name-dialog .form-error { min-height: 18px; margin: 8px 0 4px; color: var(--red); font-size: 11px; }
.dialog-submit {
  width: 100%;
  height: 52px;
  color: white;
  background: var(--green);
}
.dialog-submit:hover { background: var(--green-dark); }
.dialog-submit:disabled { cursor: wait; opacity: .65; }

footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 28px 0 42px;
  color: #959995;
  font-size: 11px;
}
.footer-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
footer small { font-size: 10px; letter-spacing: .03em; }
.footer-dot { width: 3px; height: 3px; border-radius: 50%; background: #b7bab6; }

@media (max-width: 620px) {
  .app-shell { width: min(100% - 24px, 1120px); }
  .topbar { height: 70px; }
  .sound-button span { display: none; }
  .hero { padding: 38px 0 26px; }
  .test-card { padding: 14px; border-radius: 19px; }
  .reaction-area { min-height: 300px; }
  .attempt-list { flex-wrap: wrap; }
  .result-actions { flex-direction: column; gap: 12px; }
  .ranking-panel { padding: 22px 18px 12px; }
  .name-dialog form { padding: 32px 24px 24px; }
  footer { padding-bottom: 28px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
