/* 回転寿司ゲーム — レスポンシブ・カラフル */
:root {
  --bg: #1a0f0a;
  --panel: #fff8f0;
  --accent: #e85d04;
  --accent2: #f48c06;
  --belt: #2d6a4f;
  --belt-dark: #1b4332;
  --wood: #c9a66b;
  --wood-dark: #8b6914;
  --text: #2b1d12;
  --muted: #6b5344;
  --danger: #d00000;
  --ok: #2d6a4f;
  --radius: 16px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP",
    "Segoe UI", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  max-height: 100dvh;
  margin: 0 auto;
  background: linear-gradient(180deg, #3d2314 0%, #1a0f0a 100%);
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  padding-bottom: calc(16px + var(--safe-bottom));
}

.screen.hidden {
  display: none;
}

.panel {
  background: var(--panel);
  border-radius: 24px;
  padding: 28px 24px;
  max-width: 360px;
  width: 100%;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

.title {
  margin: 0 0 8px;
  font-size: clamp(1.6rem, 6vw, 2.2rem);
  color: var(--accent);
  letter-spacing: 0.04em;
}

.subtitle {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

.howto {
  text-align: left;
  margin: 0 0 24px;
  padding: 12px 16px;
  background: #ffe8d6;
  border-radius: 12px;
  font-size: 0.88rem;
  line-height: 1.7;
  color: var(--text);
}

.howto li {
  margin-left: 4px;
}

.btn {
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: 14px 36px;
  font-size: 1.15rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.btn.primary {
  background: linear-gradient(180deg, var(--accent2), var(--accent));
  color: #fff;
  box-shadow: 0 6px 0 #9a3412;
}

.btn.primary:active {
  transform: translateY(3px);
  box-shadow: 0 3px 0 #9a3412;
}

.final-score {
  font-size: 1.25rem;
  margin: 12px 0;
}

.final-hint {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 20px;
}

/* HUD */
#hud {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  max-width: 640px;
  padding: 8px 4px 4px;
  flex-shrink: 0;
}

.hud-item {
  flex: 1;
  background: rgba(255, 248, 240, 0.95);
  border-radius: 12px;
  padding: 8px 10px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.hud-label {
  display: block;
  font-size: 0.7rem;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.06em;
}

.hud-value {
  display: block;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text);
  margin-top: 2px;
  line-height: 1.2;
}

.hud-value.lives {
  font-size: 1rem;
  letter-spacing: 1px;
}

/* Customers */
#customers {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
  max-width: 640px;
  min-height: 96px;
  padding: 8px 0 4px;
  flex-shrink: 0;
}

.customer {
  width: 76px;
  background: #fff8f0;
  border-radius: 14px;
  padding: 6px 4px 8px;
  text-align: center;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
  position: relative;
  animation: pop-in 0.35s ease;
  border: 2px solid transparent;
  transition: border-color 0.15s, transform 0.15s;
}

.customer.urgent {
  border-color: var(--danger);
  animation: shake 0.4s ease infinite;
}

.customer.served {
  transform: scale(0.85);
  opacity: 0;
  transition: all 0.3s ease;
}

@keyframes pop-in {
  from {
    transform: scale(0.5);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-2px);
  }
  75% {
    transform: translateX(2px);
  }
}

.customer-face {
  font-size: 1.6rem;
  line-height: 1;
}

.customer-order {
  font-size: 1.35rem;
  margin: 2px 0;
  line-height: 1;
}

.customer-name {
  font-size: 0.65rem;
  color: var(--muted);
  font-weight: 600;
}

.patience-bar {
  height: 6px;
  background: #e8d5c4;
  border-radius: 3px;
  margin-top: 6px;
  overflow: hidden;
}

.patience-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #52b788, #f4a261, #e63946);
  background-size: 200% 100%;
  border-radius: 3px;
  transform-origin: left center;
  transition: transform 0.1s linear;
}

/* Belt area */
#belt-area {
  flex: 1;
  width: 100%;
  max-width: 640px;
  min-height: 200px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
}

#belt-track {
  position: relative;
  width: 100%;
  height: 100%;
  max-height: 320px;
  min-height: 220px;
  border-radius: 48% / 40%;
  background: linear-gradient(145deg, var(--belt), var(--belt-dark));
  box-shadow:
    inset 0 0 0 14px var(--wood),
    inset 0 0 0 20px var(--wood-dark),
    0 8px 24px rgba(0, 0, 0, 0.4);
  overflow: hidden;
}

.belt-inner {
  position: absolute;
  left: 18%;
  top: 22%;
  right: 18%;
  bottom: 22%;
  border-radius: 45% / 40%;
  background: radial-gradient(ellipse at center, #4a2c1a 0%, #2a1810 70%);
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
}

.shop-sign {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
  pointer-events: none;
  background: rgba(255, 248, 240, 0.92);
  color: var(--accent);
  font-weight: 800;
  font-size: clamp(0.85rem, 3.5vw, 1.1rem);
  padding: 8px 16px;
  border-radius: 12px;
  letter-spacing: 0.12em;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
  border: 2px solid var(--accent2);
}

#plates {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

.plate {
  position: absolute;
  width: 56px;
  height: 56px;
  margin-left: -28px;
  margin-top: -28px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff 0%, #f0e6d8 55%, #d4c4a8 100%);
  box-shadow:
    0 3px 6px rgba(0, 0, 0, 0.35),
    inset 0 0 0 3px #e8dcc8,
    inset 0 0 0 5px #c9b896;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.7rem;
  cursor: pointer;
  pointer-events: auto;
  transition: transform 0.08s ease;
  touch-action: manipulation;
  will-change: left, top;
}

.plate:active,
.plate.tapped {
  transform: scale(1.15);
}

.plate.flash-ok {
  box-shadow: 0 0 0 4px #52b788, 0 3px 6px rgba(0, 0, 0, 0.35);
}

.plate.flash-bad {
  box-shadow: 0 0 0 4px #e63946, 0 3px 6px rgba(0, 0, 0, 0.35);
}

/* Toast */
.toast {
  position: absolute;
  bottom: calc(20px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  padding: 10px 20px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.95rem;
  z-index: 20;
  pointer-events: none;
  white-space: nowrap;
}

.toast.ok {
  background: rgba(45, 106, 79, 0.92);
}

.toast.bad {
  background: rgba(208, 0, 0, 0.92);
}

.toast.hidden {
  display: none;
}

/* Desktop / tablet tweaks */
@media (min-width: 600px) {
  .customer {
    width: 88px;
  }
  .customer-face {
    font-size: 1.9rem;
  }
  .customer-order {
    font-size: 1.55rem;
  }
  .plate {
    width: 64px;
    height: 64px;
    margin-left: -32px;
    margin-top: -32px;
    font-size: 2rem;
  }
  #belt-track {
    max-height: 380px;
    min-height: 280px;
  }
}

@media (max-height: 560px) {
  .howto {
    display: none;
  }
  #customers {
    min-height: 72px;
  }
  .customer {
    width: 64px;
    padding: 4px;
  }
  .plate {
    width: 48px;
    height: 48px;
    margin-left: -24px;
    margin-top: -24px;
    font-size: 1.4rem;
  }
}
