:root {
  color-scheme: light;
  --paper: #fff;
  --surface: #fff;
  --ink: #1f1f1f;
  --muted: #6b6b6b;
  --line: #dadada;
  --accent: #207a73;
  --accent-soft: #d8efea;
  --borrowed: #b93545;
  --own: #1e1d1b;
  --special: #8f1022;
  --yellow: #fff0a0;
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  min-height: 46px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  padding: 0 18px;
  font-weight: 750;
  cursor: pointer;
}

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

.international-shell {
  width: min(920px, calc(100% - 24px));
  margin: 0 auto;
  padding-bottom: 80px;
}

.prototype-topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 14px 0 12px;
}

.service-mark {
  border: 1px solid var(--own);
  border-radius: 6px;
  color: var(--ink);
  font-weight: 800;
  padding: 8px 12px;
  text-decoration: none;
}

.prototype-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.prototype-links {
  display: flex;
  align-items: center;
  gap: 12px;
}

.prototype-links a {
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  text-underline-offset: 3px;
}

.wallet {
  text-align: right;
}

.wallet span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.wallet strong {
  font-size: 30px;
  line-height: 1;
}

.play-section,
.deck-section,
.history-section {
  width: min(690px, 100%);
  margin: 42px auto 0;
}

.topic-row,
.deck-heading,
.history-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(38px, 8vw, 56px);
  letter-spacing: 0;
  line-height: 1;
}

h1 small {
  margin-left: 8px;
  color: var(--muted);
  font-size: 15px;
}

h2 {
  margin-bottom: 0;
  font-size: 24px;
}

.icon-command {
  width: 46px;
  min-width: 46px;
  padding: 0;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 24px;
}

.foreign-word-form {
  margin-top: 22px;
}

.foreign-word-form label {
  display: block;
  margin-bottom: 7px;
  font-size: 13px;
  font-weight: 800;
}

.foreign-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.foreign-input-row input {
  width: 100%;
  min-height: 54px;
  border: 2px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-size: 20px;
  padding: 0 14px;
}

.foreign-input-row input:focus {
  border-color: var(--accent);
  outline: 3px solid var(--accent-soft);
}

.foreign-input-row button {
  min-height: 54px;
}

.foreign-word-form > p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.translation-stage {
  margin-top: 20px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  padding: 18px;
}

.translation-stage.empty {
  opacity: 0.45;
}

.translation-stage.success {
  border-color: var(--accent);
  animation: result-arrive 320ms ease-out;
}

.translation-path {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 18px;
  font-weight: 700;
}

.translation-path i {
  font-style: normal;
}

.translation-path strong {
  color: var(--ink);
  font-size: 28px;
}

.built-kana {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 48px;
  margin-top: 15px;
}

.built-kana span {
  display: grid;
  place-items: center;
  min-width: 44px;
  height: 48px;
  border: 2px solid currentColor;
  border-radius: 6px;
  background: #fff;
  font-size: 26px;
  font-weight: 800;
}

.built-kana .borrowed {
  color: var(--borrowed);
}

.built-kana .own {
  color: var(--own);
}

.built-kana .special {
  border-color: var(--special);
  background: var(--special);
  color: #fff;
}

.score-result {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.score-result span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.score-result strong {
  color: var(--accent);
  font-size: 30px;
  line-height: 1;
}

.message {
  min-height: 24px;
  margin: 10px 0 0;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}

.message.bad {
  color: var(--borrowed);
}

.deck-heading {
  align-items: center;
}

.deck-meta,
.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: end;
  gap: 6px;
}

.deck-meta span,
.legend span {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  padding: 5px 9px;
}

.legend {
  margin: 14px 0 10px;
}

.legend .borrowed {
  border-color: #e5a3ad;
  color: var(--borrowed);
}

.legend .own {
  border-color: #8d8d8d;
  color: var(--own);
}

.legend .overlap {
  border-color: #d2ad55;
  background: var(--yellow);
  color: #705715;
}

.legend .special {
  border-color: var(--special);
  background: var(--special);
  color: #fff;
}

.kana-board-wrap {
  position: relative;
}

.kana-board {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 5px;
}

.kana-key {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  min-width: 0;
  border: 1.5px solid var(--line);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.94);
  color: #aaa7a1;
  font-size: clamp(17px, 4.5vw, 26px);
  font-weight: 800;
}

.kana-key.borrowed {
  border-color: var(--borrowed);
  color: var(--borrowed);
}

.kana-key.own {
  border-color: var(--own);
  color: var(--own);
}

.kana-key.special {
  border-color: var(--special);
  background: var(--special);
  color: #fff;
}

.kana-key.borrowed-range {
  box-shadow: inset 0 5px 0 rgba(185, 53, 69, 0.86);
}

.kana-key.own-range {
  box-shadow: inset 0 -5px 0 rgba(30, 29, 27, 0.92);
}

.kana-key.borrowed-range.own-range {
  background: var(--yellow);
}

.kana-key.used::after {
  content: attr(data-order);
  position: absolute;
  right: 3px;
  bottom: 2px;
  font-size: 9px;
  font-weight: 800;
}

.kana-key.blank {
  visibility: hidden;
}

.history-section {
  border-top: 1px solid var(--line);
  padding-top: 22px;
}

.history-heading {
  align-items: center;
}

.history-heading span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.history-list {
  display: grid;
  gap: 7px;
  margin-top: 12px;
}

.history-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 11px 12px;
}

.history-item strong {
  font-size: 16px;
}

.history-item span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.history-item > b {
  color: var(--accent);
  font-size: 18px;
}

.empty-history {
  color: var(--muted);
  font-size: 13px;
}

.prototype-note {
  display: flex;
  justify-content: center;
  gap: 8px;
  width: min(690px, 100%);
  margin: 36px auto 0;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

@keyframes result-arrive {
  from {
    opacity: 0.45;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 620px) {
  .international-shell {
    width: min(100% - 16px, 920px);
  }

  .prototype-topbar {
    grid-template-columns: auto 1fr auto;
  }

  .prototype-label {
    font-size: 10px;
  }

  .play-section,
  .deck-section,
  .history-section {
    margin-top: 30px;
  }

  .topic-row {
    align-items: center;
  }

  h1 small {
    display: block;
    margin: 6px 0 0;
  }

  .foreign-input-row {
    grid-template-columns: 1fr;
  }

  .foreign-input-row button {
    width: 100%;
  }

  .score-result {
    align-items: start;
    flex-direction: column;
  }

  .deck-heading {
    align-items: start;
    flex-direction: column;
  }

  .deck-meta,
  .legend {
    justify-content: start;
  }

  .kana-board {
    gap: 3px;
  }

  .kana-key {
    border-radius: 4px;
    font-size: clamp(15px, 5vw, 21px);
  }

  .kana-key.borrowed-range {
    box-shadow: inset 0 4px 0 rgba(185, 53, 69, 0.86);
  }

  .kana-key.own-range {
    box-shadow: inset 0 -4px 0 rgba(30, 29, 27, 0.92);
  }

  .prototype-note {
    align-items: center;
    flex-direction: column;
  }
}
