* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  background: #0a0d14;
  overflow: hidden;
  font-family: "Courier New", monospace;
  color: #eef2f6;
}

#wrap {
  position: relative;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

canvas { display: block; }

#hud {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 18px;
  padding: 8px 14px;
  background: rgba(8, 12, 22, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 6px;
  font-size: 14px;
  letter-spacing: 1px;
  pointer-events: none;
}

.hud-stat { display: grid; gap: 2px; min-width: 70px; }
.hud-stat small, .danger small { color: #83909c; font-size: 9px; font-weight: bold; letter-spacing: 1.5px; }
.hud-stat b { font-size: 14px; letter-spacing: 0; white-space: nowrap; }
.hud-zone { min-width: 96px; }
#hud-combo { color: #ffd166; }
#hud-combo.hot { color: #ff7b72; text-shadow: 0 0 8px rgba(255,123,114,.7); }
.danger { display: grid; gap: 4px; width: 78px; align-content: center; }
.danger i { display: block; width: 100%; height: 7px; border: 1px solid rgba(255,255,255,.3); background: rgba(255,255,255,.08); }
.danger em { display: block; width: 0; height: 100%; background: #ff5d52; box-shadow: 0 0 8px rgba(255,93,82,.8); transition: width .15s linear; }
#hud-score { color: #ffd98a; min-width: 70px; }
#hud-best { color: #9aa7b4; }
.hud-stat.beating #hud-best { color: #7dffa8; text-shadow: 0 0 8px rgba(125,255,168,.7); }
#lose-best { color: #9aa7b4; font-size: 13px; }
#lose-best.new-best { color: #7dffa8; font-size: 17px; font-weight: bold; text-shadow: 0 0 10px rgba(125,255,168,.8); animation: blink 0.8s step-end infinite; }
#hud-weather { color: #9fd8e8; text-transform: uppercase; }

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  /* translucent so the whole house stays visible behind the menus */
  background: linear-gradient(
    to bottom,
    rgba(6, 10, 20, 0.72),
    rgba(6, 10, 20, 0.22) 32%,
    rgba(6, 10, 20, 0.22) 68%,
    rgba(6, 10, 20, 0.72)
  );
  text-align: center;
  padding: 20px;
}

.screen h1 {
  font-size: 42px;
  letter-spacing: 8px;
  color: #f4f7fa;
  text-shadow: 0 0 18px rgba(160, 220, 180, 0.5), 0 2px 10px rgba(0, 0, 0, 0.95);
}

.screen .sub { color: #9fd8b0; letter-spacing: 3px; text-shadow: 0 1px 6px rgba(0, 0, 0, 0.9); }
.eyebrow { color: #ff9b78; font-size: 12px; font-weight: bold; letter-spacing: 4px; }
.result { display: grid; gap: 8px; min-width: 240px; }
.result strong { color: #ffd166; font-size: 28px; }
.result span { color: #b8c2cc; font-size: 13px; }

.panel {
  background: rgba(8, 12, 22, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  padding: 12px 18px;
}

.menu { display: grid; gap: 14px; justify-items: center; padding: 18px 24px 20px; }
.menu-row { display: flex; gap: 12px; align-items: stretch; flex-wrap: wrap; justify-content: center; }

.choose-label { color: #aeb9c3; font-size: 11px; font-weight: bold; letter-spacing: 3px; text-shadow: 0 1px 6px rgba(0,0,0,.9); }
.multiplayer-status { min-height: 12px; color: #7f8d98; font-size: 9px; font-weight: bold; letter-spacing: 2px; }
.multiplayer-status.connecting { color: #ffd166; }
.multiplayer-status.error { color: #ff6b57; }
.multiplayer-status.online { color: #7dffa8; }
.multiplayer-button { border-color: rgba(125,227,255,.45); color: #9fe8ff; }
.room-panel { display: grid; gap: 18px; justify-items: center; width: min(390px, 92vw); padding: 24px; }
#room-setup { width: 100%; display: grid; gap: 18px; justify-items: center; }
.room-divider { width: 100%; display: flex; align-items: center; gap: 10px; color: #65737e; font-size: 9px; font-weight: bold; letter-spacing: 2px; }
.room-divider::before, .room-divider::after { content: ''; flex: 1; height: 1px; background: rgba(255,255,255,.15); }
.join-room { display: flex; gap: 7px; }
#room-code {
  width: 96px;
  height: 38px;
  border: 1px solid rgba(255,255,255,.32);
  border-radius: 5px;
  outline: none;
  background: #111a23;
  color: #ffd166;
  font: bold 18px "Courier New", monospace;
  letter-spacing: 5px;
  text-align: center;
  text-transform: uppercase;
}
#room-code:focus { border-color: #7fe3ff; }
.room-action { min-width: 150px; height: 42px; border: 1px solid rgba(127,227,255,.45); border-radius: 5px; background: #17303b; color: #bcefff; font: bold 11px "Courier New", monospace; letter-spacing: 2px; cursor: pointer; }
.room-action:hover { background: #204554; }
.room-action:disabled { cursor: default; opacity: .48; background: #17252b; }
.create-room { width: 100%; height: 52px; background: #235849; border-color: rgba(125,255,168,.5); color: #c9ffdc; font-size: 13px; }
.room-lobby { width: 100%; display: grid; gap: 12px; justify-items: center; }
.room-lobby > small { color: #81909b; font-size: 9px; font-weight: bold; letter-spacing: 3px; }
#lobby-code { color: #ffd166; font-size: 38px; line-height: 1; letter-spacing: 9px; padding-left: 9px; }
.lobby-count { color: #a9e8ff; font-size: 11px; font-weight: bold; letter-spacing: 2px; }
.lobby-players { width: 100%; display: grid; gap: 7px; }
.lobby-player { min-height: 34px; display: flex; align-items: center; gap: 10px; padding: 0 11px; border: 1px solid rgba(255,255,255,.12); border-radius: 5px; background: rgba(255,255,255,.04); color: #e8edf1; font-size: 11px; font-weight: bold; letter-spacing: 1px; }
.lobby-player > i { width: 11px; height: 11px; border-radius: 3px; border: 1px solid rgba(255,255,255,.45); }
.lobby-player .team-badge { margin-left: auto; }
.lobby-player .team-badge small { color: #ffd166; font-size: 8px; letter-spacing: 1px; }

.chars { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.char {
  display: grid;
  gap: 5px;
  justify-items: center;
  padding: 9px 10px 7px;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 8px;
  background: rgba(8,12,22,.66);
  color: #c8d2dc;
  font-family: "Courier New", monospace;
  cursor: pointer;
  transition: transform .1s ease, border-color .1s ease;
}
.char:hover { transform: translateY(-2px); border-color: rgba(255,255,255,.45); }
.char b { font-size: 9px; font-weight: bold; letter-spacing: 1.5px; }
.char.selected {
  border-color: #ffd166;
  box-shadow: 0 0 14px rgba(255,209,102,.4), inset 0 0 8px rgba(255,209,102,.12);
  color: #ffd166;
}

.menu-button {
  width: 250px;
  height: 44px;
  border: 1px solid rgba(255,255,255,.3);
  border-radius: 6px;
  background: rgba(8,12,22,.8);
  color: #d7e0e7;
  font: bold 13px "Courier New", monospace;
  letter-spacing: 3px;
  cursor: pointer;
  transition: transform .12s ease, border-color .12s ease;
}
.menu-button:hover { transform: translateY(-1px); border-color: #ffd166; color: #ffd166; }
.menu-button:active { transform: translateY(1px); }

.end-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.end-actions .play-button, .end-actions .menu-button { width: auto; min-width: 150px; padding: 0 18px; }

.controls-line {
  position: absolute;
  bottom: 16px;
  left: 0;
  right: 0;
  text-align: center;
  color: #9aa7b3;
  font-size: 11px;
  letter-spacing: 1px;
  text-shadow: 0 1px 5px rgba(0,0,0,.9);
}

.board-title { font-size: 30px !important; letter-spacing: 6px !important; }
.big-board { min-width: 380px; list-style: none; font-size: 15px; line-height: 2; counter-reset: rank; }
.big-board li { display: flex; align-items: center; gap: 12px; padding: 0 10px; counter-increment: rank; }
.big-board li::before { content: counter(rank); color: #6a7684; min-width: 22px; text-align: right; }
.big-board li b { color: #fff; letter-spacing: 2px; flex: 1; text-align: left; }
.big-board li .board-score { min-width: 58px; color: #ffd98a; text-align: right; }
.big-board li.dim::before { content: ''; }
.char-dot { width: 11px; height: 11px; border-radius: 3px; display: inline-block; border: 1px solid rgba(255,255,255,.35); }
.team-badge { display: inline-flex; align-items: center; gap: 6px; color: #aeb9c3; white-space: nowrap; }
.team-badge img { width: 19px; height: 19px; object-fit: contain; background: #fff; border-radius: 50%; padding: 2px; }
.team-badge em { font-style: normal; font-size: 9px; font-weight: bold; letter-spacing: 1px; }
.team-badge.unknown { opacity: .55; }

.player-profile { display: grid; }
.player-profile.invalid { animation: name-shake .22s linear 2; }
.player-profile.invalid #player-name { border-color: #ff6b57; }
@keyframes name-shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
#player-name {
  width: 250px;
  height: 42px;
  padding: 0 10px;
  border: 1px solid rgba(255,255,255,.3);
  border-radius: 6px;
  outline: none;
  background: #111a23;
  color: #fff;
  font: bold 14px "Courier New", monospace;
  letter-spacing: 2px;
  text-align: center;
  text-transform: uppercase;
}
#player-name::placeholder { color: #596773; }
#player-name:focus { border-color: #ffd166; box-shadow: 0 0 0 2px rgba(255,209,102,.16); }

.play-button {
  width: 250px;
  height: 44px;
  border: 1px solid rgba(255,160,140,.55);
  border-radius: 6px;
  background: #b0281e;
  color: #fff;
  font: bold 14px "Courier New", monospace;
  letter-spacing: 3px;
  cursor: pointer;
  transition: background .12s ease, transform .12s ease;
}
.play-button:hover { background: #c93a2c; transform: translateY(-1px); }
.play-button:active { transform: translateY(1px); }
.play-button:focus-visible { outline: 2px solid #ffd166; outline-offset: 3px; }

.c-flower { color: #ff5fa8; }
.c-bomb { color: #7fe3ff; }
.c-thorn { color: #e05555; }
.c-brittle { color: #c9a15e; }

.board { min-width: 300px; }
.board h2 { font-size: 15px; letter-spacing: 4px; color: #ffd98a; margin-bottom: 8px; }
.board ol { list-style-position: inside; font-size: 14px; line-height: 1.8; }
.board li { display: flex; justify-content: space-between; gap: 20px; padding: 0 12px; }
.board li .dim, .board .dim { color: #6a7684; }
.board li b { color: #fff; letter-spacing: 2px; }

.blink { animation: blink 1.2s step-end infinite; letter-spacing: 2px; font-size: 14px; }
@keyframes blink { 50% { opacity: 0; } }

#breakdown { border-collapse: collapse; font-size: 14px; }
#breakdown td { padding: 3px 14px; text-align: left; }
#breakdown td:last-child { text-align: right; color: #ffd98a; }
#breakdown tr.total td { border-top: 1px solid rgba(255,255,255,0.3); font-weight: bold; font-size: 17px; }

#touch-controls {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(6, 48px);
  gap: 8px;
}
#touch-controls button {
  width: 48px;
  height: 48px;
  border: 1px solid rgba(255,255,255,.3);
  border-radius: 6px;
  background: rgba(8,12,22,.78);
  color: #f4f7fa;
  font: bold 22px "Courier New", monospace;
  touch-action: manipulation;
}
#touch-controls button:active, #touch-controls button.active { background: #b84b16; border-color: #ffb07a; }
#touch-lunge { font-size: 14px !important; color: #ffd166 !important; }
#touch-bomb { color: #7fe3ff !important; }

@media (pointer: fine) and (min-width: 760px) {
  #touch-controls { display: none !important; }
}

@media (max-width: 720px) {
  #hud { top: 6px; width: calc(100% - 12px); gap: 6px 12px; flex-wrap: wrap; justify-content: center; padding: 6px; }
  .hud-stat { min-width: 58px; }
  .hud-zone { min-width: 78px; }
  .danger { width: 64px; }
  .screen { gap: 12px; padding: 14px; }
  .screen h1 { font-size: 28px; letter-spacing: 4px; }
  .chars { gap: 6px; }
  .char { padding: 6px 7px 5px; }
  .char canvas { width: 40px; height: 52px; }
  .big-board { min-width: min(380px, 94vw); font-size: 13px; }
  .menu-button, .play-button, #player-name { width: 210px; }
  .menu { padding: 12px 12px 14px; width: min(440px, 96vw); }
  .controls-line { display: none; }
  .board { min-width: min(300px, 92vw); }
}

.hidden { display: none !important; }
