:root {
  --red: #E20025;
  --darkred: #BC001F;
  --white: #FFFFFF;
  color-scheme: light;
}

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

html, body {
  margin: 0;
  height: 100%;
  height: 100dvh;
  overscroll-behavior: none;
  background: var(--white);
  color: var(--white);
  font-family: 'Inter', sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
}

#app {
  width: 100%;
  max-width: 940px;
  padding: 16px;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

#stage {
  position: relative;
  width: 100%;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
  border: 3px solid var(--red);
  background: var(--darkred);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- mobile: force landscape play ---------- */
#rotateOverlay {
  display: none;
}

.touch-only { display: none; }

@media (pointer: coarse) {
  .touch-only { display: inline; }
  .desktop-only { display: none; }
}

@media (max-width: 900px) and (orientation: portrait) {
  #app { padding: 12px; }
  #stage { display: none; }
  #rotateOverlay {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    width: 100%;
    aspect-ratio: 3 / 4;
    max-height: 70vh;
    background: var(--darkred);
    border: 3px solid var(--red);
    border-radius: 14px;
    color: var(--white);
    text-align: center;
    padding: 24px;
  }
  #rotateOverlay .rotate-icon {
    font-size: 54px;
    line-height: 1;
    animation: rotate-hint 1.6s ease-in-out infinite;
  }
  #rotateOverlay p {
    margin: 0;
    font-family: 'Anton', sans-serif;
    font-size: clamp(16px, 5vw, 22px);
    letter-spacing: .5px;
  }
}

@keyframes rotate-hint {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(90deg); }
}

@media (max-width: 700px) and (orientation: landscape) {
  #app { padding: 8px; gap: 6px; }
}

canvas#game {
  display: block;
  width: 100%;
  height: auto;
  image-rendering: pixelated;
}

#hud {
  position: absolute;
  top: 10px;
  right: 16px;
  display: flex;
  gap: 18px;
  font-family: 'Anton', sans-serif;
  font-size: clamp(12px, 2.2vw, 16px);
  font-weight: normal;
  color: var(--white);
  text-shadow: 0 1px 3px rgba(188,0,31,0.9), 0 0 6px rgba(188,0,31,0.7);
  letter-spacing: 1px;
  pointer-events: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(188, 0, 31, 0.88);
  backdrop-filter: blur(2px);
  text-align: center;
  padding: 16px;
  overflow-y: auto;
}

.overlay.hidden {
  display: none;
}

.overlay h2 {
  margin: 0;
  font-family: 'Anton', sans-serif;
  font-weight: normal;
  font-size: clamp(18px, 3.4vw, 26px);
  letter-spacing: .5px;
  color: var(--white);
}

#gameOverScreen {
  justify-content: center;
  padding: clamp(4px, 1.2vh, 10px) 12px;
  gap: clamp(3px, 1vh, 7px);
}

#gameOverScreen h2 {
  font-size: clamp(12px, 2.2vh, 17px);
}

#gameOverScreen .big {
  font-size: clamp(15px, 3vh, 22px);
}

#selectScreen, #readyScreen {
  gap: clamp(6px, 2vh, 14px);
  padding: clamp(6px, 2vh, 16px);
}

#selectScreen h2 {
  font-size: clamp(14px, 4.2vh, 26px);
}

#readyScreen .big {
  font-size: clamp(13px, 3.4vh, 22px);
}

#readyScreen .hint {
  font-size: clamp(9px, 2vh, 12px);
  max-width: 420px;
}

.choices {
  display: flex;
  gap: clamp(10px, 3vw, 22px);
  flex-wrap: wrap;
  justify-content: center;
}

.choice {
  background: var(--darkred);
  border: 3px solid var(--red);
  border-radius: 12px;
  padding: clamp(6px, 1.6vh, 12px) clamp(10px, 3vw, 18px);
  color: var(--white);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(3px, 1vh, 6px);
  width: 170px;
  transition: transform .12s ease, border-color .12s ease;
}
.choice:hover, .choice:focus-visible {
  transform: translateY(-4px);
  border-color: var(--white);
}
.choice img {
  width: clamp(46px, 11vh, 84px);
  height: auto;
  image-rendering: pixelated;
}
.choice span {
  font-family: 'Anton', sans-serif;
  font-weight: normal;
  font-size: clamp(12px, 2.6vh, 16px);
  letter-spacing: 1px;
}
.choice small {
  font-size: clamp(8px, 1.8vh, 10.5px);
  opacity: 0.85;
  line-height: 1.25;
}

.hint {
  max-width: 480px;
  font-size: clamp(9px, 2vh, 12px);
  opacity: 0.9;
  margin: 0;
}

.big {
  font-family: 'Anton', sans-serif;
  font-weight: normal;
  font-size: clamp(16px, 3vw, 22px);
  margin: 0;
}

#finalScore {
  color: var(--white);
  font-size: clamp(28px, 6vw, 44px);
}

.explainer {
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  gap: clamp(4px, 1vw, 10px);
  width: 100%;
  max-width: 860px;
  margin: 0;
}

.explain-card {
  background: var(--darkred);
  border: 2px solid var(--red);
  border-radius: 7px;
  padding: 4px 5px 5px;
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.explain-card img {
  height: clamp(38px, 9vh, 78px);
  width: 100%;
  object-fit: contain;
}

.explain-card b {
  font-family: 'Anton', sans-serif;
  font-weight: normal;
  font-size: clamp(8px, 1.6vh, 11px);
  color: var(--white);
  letter-spacing: .1px;
  line-height: 1.15;
}

.explain-card small {
  font-size: clamp(6.5px, 1.25vh, 8.5px);
  line-height: 1.15;
  opacity: 0.9;
}

.actions {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

button#changeCharBtn,
button#changeCharBtn2,
button#retryBtn {
  background: var(--red);
  color: var(--white);
  border: none;
  padding: 10px 20px;
  min-height: 42px;
  border-radius: 8px;
  font-family: 'Anton', sans-serif;
  font-weight: normal;
  font-size: 15px;
  cursor: pointer;
  letter-spacing: .5px;
  touch-action: manipulation;
}
button#changeCharBtn {
  background: transparent;
  color: var(--white);
  border: 2px solid var(--white);
}

#gameOverScreen button {
  padding: clamp(4px, 1vh, 7px) clamp(8px, 2vw, 16px);
  font-size: clamp(10px, 2vh, 14px);
  min-height: clamp(28px, 6vh, 40px);
}

@media (max-width: 480px) {
  .choice { width: 130px; padding: 10px; }
  .choice img { width: 62px; }
}
