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

:root {
  --bg: #14171f;
  --card: #1f2330;
  --accent: #ff5d73;
  --accent2: #4fd1c5;
  --text: #f2f2f5;
  --muted: #9296a6;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}

.page {
  max-width: 480px;
  margin: 0 auto;
  padding: env(safe-area-inset-top, 16px) 18px calc(env(safe-area-inset-bottom, 16px) + 24px);
  min-height: 100vh;
}

h1 {
  font-size: 22px;
  margin: 12px 0 4px;
}
.subtitle {
  color: var(--muted);
  font-size: 14px;
  margin: 0 0 20px;
}

.card {
  background: var(--card);
  border-radius: 18px;
  padding: 20px;
  margin-bottom: 16px;
}

label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin: 14px 0 6px;
}
label:first-child { margin-top: 0; }

input[type="text"], input[type="number"] {
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid #333849;
  background: #0f1118;
  color: var(--text);
  font-size: 16px;
}
input:focus { outline: 2px solid var(--accent2); }

.btn {
  display: block;
  width: 100%;
  padding: 16px;
  border-radius: 14px;
  border: none;
  font-size: 17px;
  font-weight: 700;
  min-height: 52px;
  cursor: pointer;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-secondary { background: #2b3040; color: var(--text); }
.btn:disabled { opacity: 0.4; }

.error-msg {
  color: var(--accent);
  font-size: 14px;
  margin: 8px 0;
}

.qr-box {
  text-align: center;
  padding: 16px 0;
}
.qr-box img { width: 200px; height: 200px; border-radius: 12px; background: #fff; padding: 10px; }
.room-code {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: 4px;
  text-align: center;
  margin: 10px 0 4px;
}
.join-url {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  word-break: break-all;
}

.lane-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 10px;
  margin: 14px 0;
}
.lane-cell {
  background: #0f1118;
  border: 2px solid #2b3040;
  border-radius: 12px;
  padding: 10px 6px;
  text-align: center;
  font-size: 13px;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, border-color 0.2s;
}
.lane-cell.filled {
  background: rgba(79, 209, 197, 0.15);
  border-color: var(--accent2);
  color: var(--accent2);
  font-weight: 700;
}
.lane-cell.mine {
  background: rgba(255, 93, 115, 0.18);
  border-color: var(--accent);
  color: var(--accent);
}
.lane-cell.clickable { cursor: pointer; }
.lane-cell.empty-num { color: var(--muted); }

canvas#ladder-canvas {
  width: 100%;
  height: auto;
  aspect-ratio: 480 / 640;
  background: #0f1118;
  border-radius: 16px;
  display: block;
}

.result-list {
  margin-top: 16px;
}
.result-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 4px;
  border-bottom: 1px solid #2b3040;
  font-size: 15px;
}
.result-row:last-child { border-bottom: none; }
.result-row .name { font-weight: 700; }
.result-row .value { color: var(--accent2); }

.big-reveal {
  text-align: center;
  padding: 30px 10px;
}
.big-reveal .emoji { font-size: 56px; }
.big-reveal .value {
  font-size: 30px;
  font-weight: 800;
  color: var(--accent2);
  margin-top: 10px;
}
.big-reveal .name {
  color: var(--muted);
  margin-top: 6px;
}

.waiting-note {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  margin-top: 10px;
}

.hidden { display: none !important; }

.footer-links {
  margin: 28px 0 12px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}
.footer-links a { color: #b7bac6; text-decoration: none; }
.footer-links a:hover { text-decoration: underline; }
.footer-links span { margin: 0 6px; }

.host-join-row {
  background: #0f1118;
  border: 1px solid #2b3040;
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 14px;
}
.host-join-row input {
  padding: 12px;
  font-size: 15px;
}

.canvas-wrap {
  position: relative;
}

#all-results { margin-top: 4px; }
#all-results label { display: block; margin-top: 18px; }
