:root {
  color-scheme: light;
  --ink: #16231d;
  --muted: #52635d;
  --panel: rgba(255, 255, 255, 0.86);
  --panel-strong: rgba(255, 255, 255, 0.95);
  --tea: #1f7a4d;
  --tea-dark: #155f42;
  --new-leaf: #9fe457;
  --gold: #f6c43f;
  --warning: #9b4d2f;
  --sky: #8ed4f7;
  --line: rgba(22, 35, 29, 0.16);
  --shadow: 0 18px 46px rgba(16, 55, 39, 0.24);
  font-family:
    "Hiragino Sans",
    "Yu Gothic",
    "YuGothic",
    "Noto Sans JP",
    system-ui,
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background: #0c4d38;
  color: var(--ink);
}

button,
canvas {
  -webkit-tap-highlight-color: transparent;
}

.game-shell {
  position: fixed;
  inset: 0;
  min-width: 320px;
  min-height: 100dvh;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(142, 212, 247, 0.35), rgba(21, 95, 66, 0.3)),
    #166344;
  touch-action: none;
  user-select: none;
}

#gameCanvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.hud {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  left: max(14px, env(safe-area-inset-left));
  right: max(14px, env(safe-area-inset-right));
  z-index: 3;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  pointer-events: none;
}

.brand {
  min-width: 0;
  color: white;
  text-shadow: 0 2px 12px rgba(5, 43, 29, 0.42);
}

.brand-kicker {
  display: block;
  margin-bottom: 2px;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.25rem, 5.6vw, 2.3rem);
  line-height: 1.02;
  letter-spacing: 0;
}

.meters {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.meter {
  min-width: 68px;
  padding: 9px 10px 8px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 10px 24px rgba(13, 64, 44, 0.16);
  text-align: center;
  backdrop-filter: blur(12px);
}

.meter span {
  display: block;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1;
}

.meter strong {
  display: block;
  margin-top: 3px;
  color: var(--tea-dark);
  font-size: 1.28rem;
  line-height: 1;
}

.tray {
  position: absolute;
  left: max(14px, env(safe-area-inset-left));
  right: max(14px, env(safe-area-inset-right));
  bottom: max(14px, env(safe-area-inset-bottom));
  z-index: 3;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(118px, 22vw);
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.66);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  pointer-events: none;
}

.tray p {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 0.94rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quality {
  min-width: 0;
}

.quality span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 800;
}

.quality-bar {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(21, 95, 66, 0.16);
}

.quality-bar i {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--new-leaf), var(--gold));
  transition: width 180ms ease;
}

.dialog {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    radial-gradient(circle at 50% 78%, rgba(255, 255, 255, 0.12), transparent 34%),
    rgba(9, 41, 29, 0.34);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.dialog.is-open {
  opacity: 1;
  pointer-events: auto;
}

.dialog-panel {
  width: min(430px, 100%);
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 8px;
  background: var(--panel-strong);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.eyebrow {
  margin-bottom: 8px;
  color: var(--tea-dark);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.dialog h2 {
  margin-bottom: 10px;
  color: var(--ink);
  font-size: clamp(1.6rem, 8vw, 2.55rem);
  line-height: 1.08;
  letter-spacing: 0;
}

.dialog p:not(.eyebrow) {
  color: var(--muted);
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1.72;
}

.primary-button {
  width: 100%;
  min-height: 48px;
  margin-top: 18px;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--tea-dark), #224c87);
  box-shadow: 0 12px 26px rgba(18, 72, 55, 0.28);
  color: white;
  cursor: pointer;
  font: inherit;
  font-size: 1rem;
  font-weight: 900;
}

.primary-button:active {
  transform: translateY(1px);
}

.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
}

.result-grid div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(31, 122, 77, 0.08);
}

.result-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
}

.result-grid strong {
  display: block;
  margin-top: 5px;
  color: var(--tea-dark);
  font-size: 1.65rem;
  line-height: 1;
}

@media (max-width: 700px) {
  .hud {
    grid-template-columns: 1fr;
    gap: 9px;
  }

  .meters {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .meter {
    min-width: 0;
    padding-inline: 8px;
  }

  .tray {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .tray p {
    white-space: normal;
  }

  .quality {
    width: 100%;
  }

  .dialog {
    align-items: end;
    padding: 14px;
  }

  .dialog-panel {
    padding: 20px;
  }
}

@media (max-height: 560px) and (orientation: landscape) {
  .hud {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  h1 {
    font-size: 1.25rem;
  }

  .meter {
    min-width: 58px;
    padding: 7px 8px;
  }

  .meter strong {
    font-size: 1.04rem;
  }

  .tray {
    width: min(440px, calc(100vw - 28px));
    right: auto;
  }

  .dialog-panel {
    width: min(500px, 100%);
    padding: 18px;
  }

  .dialog h2 {
    font-size: 1.7rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
