* { box-sizing: border-box; }
html, body { width: 100%; min-height: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: radial-gradient(circle at top, #17315f, #050816 62%);
  color: #eaf6ff;
  font-family: Segoe UI, Arial, sans-serif;
}
body:not(.authenticated) main { display: none; }
body.authenticated .login-card { display: none; }
body:not(.authenticated) .setup-card { display: none; }
body.authenticated .setup-card { display: block; }
body.authenticated .setup-card.hidden { display: none; }
.setup-card, .login-card {
  padding: 24px;
  border: 1px solid #315b99;
  border-radius: 18px;
  background: #0b1730;
}
.setup-card { width: min(92vw, 700px); margin: 5vh auto 0; }
.login-card { width: min(92vw, 380px); margin: 12vh auto 0; }
.setup-card.hidden { display: none; }
.setup-card > label { margin: 14px 0; }
.setup-card select { min-height: 42px; }
.setup-card button { margin-top: 18px; min-height: 44px; }
.login-card form { display: grid; gap: 10px; }
.login-card input, .login-card button { width: 100%; min-height: 46px; }
.error { min-height: 22px; margin-top: 12px; color: #ff7f8d; }
.account { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; color: #8cfffb; }
.account button { padding: 7px 10px; }
main {
  display: grid;
  grid-template-columns: auto minmax(320px, 460px);
  gap: 22px;
  justify-content: center;
  padding: 28px;
}
.live-screen { display: none; }
.live-screen.active {
  display: grid;
  width: 100vw;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 0;
  place-items: center;
  overflow: hidden;
  background: #02040a;
}
.live-screen.active .panel { display: none; }
.game-card {
  display: grid;
  grid-template-rows: 29.6875% 70.3125%;
  width: min(100vw, calc(100dvh * 9 / 16));
  height: min(100dvh, calc(100vw * 16 / 9));
  overflow: hidden;
  background: #071126;
  box-shadow: 0 0 80px #0008;
}
.gift-list {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 0;
  padding: max(14px, env(safe-area-inset-top)) 16px 12px;
  background: linear-gradient(180deg, #122b54, #0b1830);
  border-bottom: 1px solid #55dfff66;
}
.gift-list-title {
  margin-bottom: 10px;
  color: #8cffff;
  font-size: clamp(11px, 2.2vw, 16px);
  font-weight: 900;
  letter-spacing: .12em;
  text-align: center;
}
#trigger-guide {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  align-content: start;
  gap: 7px;
  min-height: 0;
  pointer-events: none;
}
.trigger-card {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
}
.trigger-card img { position: absolute; inset: 20%; width: 60%; height: 60%; object-fit: contain; }
.trigger-card span {
  position: absolute;
  top: 50%;
  right: 0;
  left: 0;
  overflow: hidden;
  padding: 3px 2px;
  transform: translateY(-50%);
  color: #d8f7ff;
  font: 800 clamp(7px, 1.6vw, 11px)/1.1 Segoe UI, sans-serif;
  text-align: center;
  text-overflow: ellipsis;
  text-shadow: 0 1px 2px #000;
  white-space: nowrap;
}
.play-area { position: relative; min-height: 0; background: #071126; }
canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  background: #071126;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.leave-game {
  position: absolute;
  z-index: 3;
  top: 12px;
  left: 14px;
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 50%;
  font-size: 26px;
}
.reset-game {
  position: absolute;
  z-index: 3;
  top: 14px;
  right: 14px;
  width: auto;
  min-height: 30px;
  padding: 5px 8px;
  border-color: #ffdf72;
  background: #24142bcc;
  color: #fff0af;
  font-size: 10px;
}
.steering {
  position: absolute;
  z-index: 3;
  left: 18px;
  right: 18px;
  bottom: max(18px, env(safe-area-inset-bottom));
  display: flex;
  justify-content: space-between;
  pointer-events: none;
}
.steering button {
  width: 68px;
  height: 68px;
  padding: 0;
  border: 2px solid #9defff;
  border-radius: 50%;
  background: #0a294dcc;
  color: white;
  font-size: 0;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
}
.steering button::before {
  content: '';
  display: block;
  width: 0;
  height: 0;
  margin: auto;
  border-top: 11px solid transparent;
  border-bottom: 11px solid transparent;
}
.steering .laser-button {
  border-color: #ffd85a;
  background: #4b265dcc;
  color: #fff6a2;
  font-size: 30px;
  line-height: 1;
}
.steering .laser-button::before { display: none; }
#move-left::before { border-right: 17px solid white; }
#move-right::before { border-left: 17px solid white; }
#banner {
  position: absolute;
  z-index: 2;
  top: 16px;
  right: 16px;
  left: 70px;
  text-align: center;
  font-weight: 900;
  color: #8cfffb;
  text-shadow: 0 3px #00111f;
}
.panel {
  padding: 22px;
  border: 1px solid #315b99;
  border-radius: 18px;
  background: #0b1730d9;
}
h1, h2 { margin: 0 0 12px; }
h2 { margin-top: 22px; font-size: 16px; color: #70e9ff; }
.muted { color: #9db4d5; }
.row, .test-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
input, select, button {
  border: 1px solid #315b99;
  border-radius: 10px;
  padding: 10px 12px;
  background: #081427;
  color: #eaf6ff;
}
button { cursor: pointer; font-weight: 800; background: linear-gradient(135deg, #2b8cff, #50e6ff); color: #06101e; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
label { display: grid; gap: 6px; color: #b9cae9; }
.status { margin-top: 10px; padding: 10px; border-radius: 10px; background: #071126; color: #ffe66d; }
.recent { display: grid; gap: 8px; max-height: 180px; overflow: auto; }
.recent div { padding: 8px 10px; border-radius: 10px; background: #071126; color: #cbdcff; }
@media (max-width: 900px) {
  main { grid-template-columns: 1fr; padding: 10px; gap: 10px; }
  .panel { padding: 10px; border-radius: 14px; }
  .grid { grid-template-columns: 1fr; }
  input, select, button { width: 100%; min-height: 44px; font-size: 16px; }
  .row button, .test-buttons button { flex: 1 1 130px; }
}
@media (max-width: 430px) {
  .gift-list { padding-left: 10px; padding-right: 10px; }
  #trigger-guide { gap: 5px; }
  .steering { left: 14px; right: 14px; }
  .steering button { width: 60px; height: 60px; }
}
