:root {
  color-scheme: dark;
  font-family:
    Inter, Pretendard, "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont,
    sans-serif;
  background: #111317;
  color: #f7f4ea;
}

html {
  width: 100%;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

* {
  box-sizing: border-box;
}

body {
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
  touch-action: manipulation;
  display: grid;
  justify-items: center;
  align-items: start;
  background:
    radial-gradient(circle at 10% 10%, rgba(49, 154, 141, 0.24), transparent 32rem),
    radial-gradient(circle at 90% 20%, rgba(238, 94, 94, 0.18), transparent 30rem),
    linear-gradient(135deg, #101216, #1c2027 48%, #17191f);
}

button {
  border: 0;
  border-radius: 8px;
  background: #f7d44a;
  color: #211b0b;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  min-height: 42px;
  padding: 0 16px;
  box-shadow: 0 6px 0 #b4871d;
  transition:
    transform 120ms ease,
    box-shadow 120ms ease,
    filter 120ms ease;
}

button:hover {
  filter: brightness(1.06);
}

button:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #b4871d;
}

button:disabled {
  cursor: default;
  filter: grayscale(0.55) brightness(0.78);
  opacity: 0.7;
}

button:disabled:active {
  transform: none;
  box-shadow: 0 6px 0 #b4871d;
}

.game-shell {
  width: min(96vw, 680px);
  display: grid;
  gap: 12px;
  padding: 12px 16px 16px;
}

.topbar {
  display: grid;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 12px;
  backdrop-filter: blur(12px);
}

.topbar {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.account-chip {
  grid-column: 1 / -1;
  justify-self: end;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  border: 1px solid rgba(159, 240, 219, 0.35);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.22);
  padding: 5px 6px 5px 10px;
  color: #fffaf0;
  font-size: 12px;
  font-weight: 900;
}

.account-chip[hidden] {
  display: none;
}

.account-chip span {
  max-width: 132px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-chip button {
  min-height: 28px;
  padding: 0 9px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.1);
  color: #9ff0db;
  border: 1px solid rgba(159, 240, 219, 0.32);
  box-shadow: none;
  font-size: 11px;
}

.topbar.duel-mode .time-card {
  grid-column: 1 / -1;
  min-height: 46px;
}

.topbar.duel-mode .time-head {
  margin-bottom: 8px;
}

.topbar > div {
  min-width: 0;
}

.score-card,
.opponent-score-card,
.time-card {
  min-height: 72px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  position: relative;
  overflow: hidden;
}

.score-card,
.opponent-score-card {
  padding: 10px 14px 10px 58px;
}

.score-card {
  background:
    radial-gradient(circle at 24px 32px, #fff6a8 0 8px, #f7d44a 9px 20px, #b4871d 21px 25px, transparent 26px),
    linear-gradient(145deg, rgba(255, 230, 106, 0.28), rgba(255, 132, 89, 0.2));
}

.opponent-score-card {
  background:
    radial-gradient(circle at 24px 32px, #d7f3ff 0 8px, #58a6ff 9px 20px, #2869b8 21px 25px, transparent 26px),
    linear-gradient(145deg, rgba(88, 166, 255, 0.3), rgba(69, 198, 168, 0.18));
}

.opponent-score-card[hidden] {
  display: none;
}

.score-card[hidden] {
  display: none;
}

.multi-score-board {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
  gap: 8px;
}

.multi-score-board[hidden] {
  display: none;
}

.multi-score-item {
  position: relative;
  min-width: 0;
  max-width: none;
  min-height: 66px;
  display: grid;
  align-content: center;
  gap: 3px;
  overflow: hidden;
  padding: 9px 11px 9px 42px;
  border-radius: 8px;
  background:
    radial-gradient(circle at 20px 30px, #d7f3ff 0 6px, #58a6ff 7px 16px, #2869b8 17px 20px, transparent 21px),
    linear-gradient(145deg, rgba(88, 166, 255, 0.26), rgba(69, 198, 168, 0.15)),
    rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(142, 184, 255, 0.25);
}

.multi-score-item.me {
  background:
    radial-gradient(circle at 20px 30px, #fff6a8 0 6px, #f7d44a 7px 16px, #b4871d 17px 20px, transparent 21px),
    linear-gradient(145deg, rgba(247, 212, 74, 0.3), rgba(255, 132, 89, 0.18)),
    rgba(255, 255, 255, 0.08);
  border-color: rgba(247, 212, 74, 0.42);
}

.multi-score-item::after {
  content: "";
  position: absolute;
  left: 22px;
  top: 18px;
  width: 5px;
  height: 22px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.35);
  transform: rotate(28deg);
}

.multi-score-item span {
  overflow: hidden;
  color: #b7bec9;
  font-size: 11px;
  font-weight: 950;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.multi-score-item.me span {
  color: #fff4c2;
}

.multi-score-item strong {
  overflow: hidden;
  color: #ffffff;
  font-size: 22px;
  font-weight: 1000;
  line-height: 1;
  text-overflow: ellipsis;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.22);
}

.score-card::after,
.opponent-score-card::after {
  content: "";
  position: absolute;
  left: 28px;
  top: 18px;
  width: 7px;
  height: 28px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.42);
  transform: rotate(28deg);
}

.time-card {
  padding: 10px 14px;
  background:
    linear-gradient(145deg, rgba(69, 198, 168, 0.24), rgba(88, 166, 255, 0.2)),
    rgba(255, 255, 255, 0.06);
}

.time-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.time-track {
  height: 15px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.28);
}

.time-fill {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  transform: scaleX(1);
  transform-origin: left center;
  background: linear-gradient(90deg, #ee5a5a 0%, #f7d44a 42%, #45c6a8 100%);
  box-shadow: 0 0 16px rgba(247, 212, 74, 0.34);
  transition: transform 340ms linear;
}

.time-card.time-paused {
  animation: time-pause-pulse 520ms ease-in-out infinite alternate;
}

.time-card.time-bonus {
  animation: time-bonus-pop 620ms cubic-bezier(0.17, 0.9, 0.28, 1);
}

.label {
  display: block;
  color: #b7bec9;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

strong {
  display: block;
  color: #ffffff;
  font-size: 28px;
  line-height: 1;
}

.score-card strong,
.opponent-score-card strong,
.time-card strong {
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.22);
}

.duel-record {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  overflow: hidden;
  border-radius: 8px;
  padding: 7px 10px;
  background:
    linear-gradient(90deg, rgba(247, 212, 74, 0.16), rgba(88, 166, 255, 0.16)),
    rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #eef4ff;
  font-size: 13px;
  font-weight: 850;
  line-height: 1.1;
  text-align: center;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(12px);
}

.duel-player {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, auto) auto auto;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 6px 9px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.16);
}

.duel-player.leading {
  background:
    linear-gradient(135deg, rgba(247, 212, 74, 0.26), rgba(69, 198, 168, 0.16)),
    rgba(255, 255, 255, 0.12);
  border-color: rgba(247, 212, 74, 0.58);
  box-shadow: 0 0 18px rgba(247, 212, 74, 0.2);
}

.duel-player strong {
  min-width: 0;
  overflow: hidden;
  color: #ffffff;
  font-size: 14px;
  font-weight: 950;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.duel-player span {
  color: #fff6a8;
  font-size: 12px;
  font-weight: 1000;
}

.duel-player em {
  display: inline-grid;
  place-items: center;
  min-height: 18px;
  border-radius: 999px;
  padding: 0 6px;
  background: #45c6a8;
  color: #071f1a;
  font-size: 10px;
  font-style: normal;
  font-weight: 1000;
  box-shadow: 0 2px 0 #21806d;
}

.duel-player.waiting {
  color: #b7bec9;
  font-weight: 900;
}

.duel-vs {
  display: grid;
  place-items: center;
  min-width: 34px;
  height: 28px;
  border-radius: 999px;
  background: #f7d44a;
  color: #211b0b;
  font-size: 12px;
  font-weight: 1000;
  box-shadow: 0 3px 0 #9d6a16;
}

.duel-record[hidden] {
  display: none;
}

.stage-wrap {
  position: relative;
  display: grid;
  place-items: center;
  min-height: min(86vw, 620px);
  border-radius: 8px;
  overflow: hidden;
  background: #252b33;
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.42);
}

#stage {
  width: min(100%, 620px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.stage-wrap.duel-mode canvas {
  filter: blur(2px) brightness(0.72) saturate(0.82);
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
  background: rgba(15, 18, 23, 0.72);
  backdrop-filter: blur(8px);
}

.combo-pop {
  pointer-events: none;
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 3;
  min-width: 0;
  padding: 0;
  text-align: center;
  background: transparent;
  border: 0;
  box-shadow: none;
  color: #ffffff;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.58) rotate(-7deg);
  filter:
    drop-shadow(0 6px 0 #7e2e24)
    drop-shadow(0 0 18px rgba(255, 236, 116, 0.95))
    drop-shadow(0 0 34px rgba(255, 92, 92, 0.72));
}

.combo-pop.show {
  animation: combo-burst 740ms cubic-bezier(0.17, 0.9, 0.28, 1) forwards;
}

.combo-pop strong {
  color: #fff9b8;
  font-size: clamp(76px, 17vw, 150px);
  line-height: 0.78;
  text-shadow:
    0 4px 0 #ff7a18,
    0 9px 0 #9d2e24,
    0 0 18px rgba(255, 255, 255, 0.95),
    0 0 34px rgba(255, 214, 64, 0.9);
}

.combo-pop span {
  display: block;
  margin-top: 8px;
  font-size: clamp(30px, 7vw, 62px);
  font-weight: 1000;
  color: #ffffff;
  text-shadow:
    0 3px 0 #e8505b,
    0 7px 0 #7e2e24,
    0 0 20px rgba(255, 255, 255, 0.82);
}

.attack-hit {
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  text-align: center;
  opacity: 0;
  background: rgba(238, 90, 90, 0);
}

.attack-hit[aria-hidden="true"] {
  display: none;
}

.attack-hit.show {
  display: grid;
  animation: attack-flash 720ms cubic-bezier(0.17, 0.9, 0.28, 1) forwards;
}

.attack-hit strong {
  color: #fff4f0;
  font-size: clamp(64px, 15vw, 132px);
  line-height: 0.82;
  text-shadow:
    0 5px 0 #9d2e24,
    0 0 20px rgba(255, 255, 255, 0.9),
    0 0 36px rgba(238, 90, 90, 0.86);
}

.attack-hit span {
  display: block;
  color: #ffd2cb;
  font-size: clamp(24px, 5vw, 48px);
  font-weight: 1000;
  text-shadow: 0 3px 0 #7e2e24;
}

.stage-wrap.under-attack canvas {
  animation: board-hit-shake 360ms cubic-bezier(0.17, 0.9, 0.28, 1);
}

.overlay.hidden {
  display: none;
}

#play {
  background: rgba(247, 212, 74, 0.22);
  color: #fff4c2;
  border: 1px solid rgba(247, 212, 74, 0.38);
  box-shadow: none;
}

.overlay h1 {
  margin: 0;
  font-size: clamp(40px, 8vw, 74px);
  line-height: 0.95;
}

.overlay.result-win {
  background:
    linear-gradient(rgba(15, 18, 23, 0.54), rgba(15, 18, 23, 0.54)),
    radial-gradient(circle at 50% 38%, rgba(247, 212, 74, 0.44), transparent 24rem);
}

.overlay.result-win h1 {
  color: #fff6a8;
  text-shadow: 0 5px 0 #9d6a16, 0 0 26px rgba(247, 212, 74, 0.72);
}

.overlay.result-lose {
  background:
    linear-gradient(rgba(15, 18, 23, 0.62), rgba(15, 18, 23, 0.62)),
    radial-gradient(circle at 50% 38%, rgba(238, 90, 90, 0.34), transparent 24rem);
}

.overlay.result-lose h1 {
  color: #ffb4ac;
  text-shadow: 0 5px 0 #7e2e24, 0 0 24px rgba(238, 90, 90, 0.64);
}

.overlay.result-draw h1 {
  color: #d8dee8;
  text-shadow: 0 5px 0 rgba(0, 0, 0, 0.32);
}

.overlay p {
  max-width: 34rem;
  margin: 0;
  color: #d8dee8;
}

.leaderboard {
  display: grid;
  gap: 10px;
  border-radius: 8px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(12px);
}

.leaderboard-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.leaderboard-head strong {
  color: #fff6a8;
  font-size: 20px;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.24);
}

.leaderboard-head span {
  color: #b7bec9;
  font-size: 13px;
  font-weight: 800;
}

.leaderboard-list {
  min-height: 44px;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 7px;
  list-style: none;
}

.leaderboard-list li {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 7px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.leaderboard-list li::before {
  content: counter(list-item);
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #f7d44a;
  color: #211b0b;
  font-size: 13px;
  font-weight: 1000;
  box-shadow: 0 3px 0 #b4871d;
}

.leaderboard-list span {
  min-width: 0;
  overflow: hidden;
  color: #eef4ff;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-list strong {
  color: #ffffff;
  font-size: 18px;
  text-align: right;
}

.network-panel {
  display: grid;
  gap: 10px;
  border-radius: 8px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(12px);
}

.network-panel[hidden] {
  display: none;
}

.leaderboard[hidden],
.player-list[hidden] {
  display: none;
}

.network-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.network-head strong {
  color: #9ff0db;
  font-size: 20px;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.24);
}

.network-head span {
  color: #b7bec9;
  font-size: 13px;
  font-weight: 800;
}

.network-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 112px auto;
  gap: 8px;
}

.network-form.nickname-only {
  grid-template-columns: minmax(0, 1fr) auto;
}

.network-form[hidden] {
  display: none;
}

.network-form input[hidden] {
  display: none;
}

.network-form input {
  min-width: 0;
  min-height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.22);
  padding: 0 12px;
  color: #fffaf0;
  font: inherit;
  font-weight: 800;
}

.network-form input:focus {
  outline: 2px solid rgba(159, 240, 219, 0.7);
  outline-offset: 2px;
}

.game-master-login {
  width: 100%;
  background: #9ff0db;
  color: #10201d;
  box-shadow: 0 6px 0 #398f7c;
}

.game-master-login[hidden] {
  display: none;
}

.room-lobby {
  display: grid;
  gap: 9px;
}

.room-lobby[hidden] {
  display: none;
}

.room-lobby-actions,
.room-create-form {
  display: grid;
  gap: 8px;
}

.room-lobby-actions {
  grid-template-columns: 1fr;
  width: 100%;
}

.room-lobby-actions .create-room {
  display: block;
  width: 100%;
}

.room-create-form input,
.room-create-form select {
  width: 100%;
  min-height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.22);
  padding: 0 12px;
  color: #fffaf0;
  font: inherit;
  font-weight: 850;
}

.room-create-form select {
  appearance: none;
  background:
    linear-gradient(45deg, transparent 50%, #9ff0db 50%) calc(100% - 18px) 18px / 7px 7px no-repeat,
    linear-gradient(135deg, #9ff0db 50%, transparent 50%) calc(100% - 13px) 18px / 7px 7px no-repeat,
    rgba(0, 0, 0, 0.22);
  padding-right: 34px;
  color: #9ff0db;
}

.room-create-form select option {
  background: #202832;
  color: #fffaf0;
}

.room-create-form select:hover {
  border-color: rgba(159, 240, 219, 0.52);
}

.room-create-form input[hidden] {
  display: none;
}

.room-create-form input:focus,
.room-create-form select:focus {
  outline: 2px solid rgba(159, 240, 219, 0.7);
  outline-offset: 2px;
}

.room-create-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.room-create-grid label {
  display: grid;
  gap: 5px;
}

.room-create-grid span {
  color: #b7bec9;
  font-size: 11px;
  font-weight: 900;
}

.create-room,
.change-name {
  width: 100%;
}

.create-room {
  background: rgba(142, 184, 255, 0.22);
  color: #dce8ff;
  border: 1px solid rgba(142, 184, 255, 0.36);
  box-shadow: none;
}

.change-name {
  background: #45c6a8;
  color: #071f1a;
  box-shadow: 0 6px 0 #21806d;
}

.change-name:active {
  box-shadow: 0 2px 0 #21806d;
}

#play:active,
.create-room:active,
.account-chip button:active,
.room-list button:active {
  transform: none;
  box-shadow: none;
}

.room-list {
  min-height: 44px;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 7px;
  list-style: none;
}

.room-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 76px auto;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 7px 8px 7px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.room-list li.empty {
  display: block;
  color: #b7bec9;
  font-size: 13px;
  font-weight: 800;
}

.room-list span {
  min-width: 0;
  overflow: hidden;
  color: #eef4ff;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-list span em {
  margin-left: 6px;
  color: #ffd45c;
  font-style: normal;
}

.room-list small {
  color: #9ff0db;
  font-size: 12px;
  font-weight: 900;
  text-align: right;
}

.room-list button {
  min-height: 34px;
  padding: 0 12px;
  background: rgba(247, 212, 74, 0.18);
  color: #fff4c2;
  border: 1px solid rgba(247, 212, 74, 0.34);
  box-shadow: none;
}

.room-chat {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 6;
  display: grid;
  gap: 8px;
  padding: 10px;
  border-radius: 8px;
  background: rgba(15, 18, 23, 0.64);
  border: 1px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(8px);
}

.room-chat[hidden] {
  display: none;
}

.room-chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.room-chat-head > div:first-child {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 7px;
}

.room-chat-head strong {
  color: #9ff0db;
  font-size: 14px;
  font-weight: 1000;
}

.room-chat-head span {
  flex-basis: 100%;
  color: #b7bec9;
  font-size: 11px;
  font-weight: 850;
}

.room-participant-count {
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(247, 212, 74, 0.16);
  border: 1px solid rgba(247, 212, 74, 0.3);
  color: #fff4c2;
  font-size: 11px;
  font-style: normal;
  font-weight: 950;
}

.room-participant-count[hidden] {
  display: none;
}

.room-chat-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.room-chat-actions button {
  width: auto;
  min-height: 30px;
  padding: 0 9px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 950;
}

.room-chat-list {
  display: grid;
  align-content: start;
  gap: 6px;
  max-height: min(184px, 28vw);
  min-height: 116px;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

.room-chat-list li {
  justify-self: start;
  display: grid;
  gap: 3px;
  max-width: 82%;
  padding: 0;
  background: transparent;
}

.room-chat-list li.me {
  justify-self: end;
  text-align: right;
}

.room-chat-list li.other {
  border: 0;
}

.room-chat-list li.tone-1 strong {
  color: #ff9b88;
}

.room-chat-list li.tone-2 strong {
  color: #ffd966;
}

.room-chat-list li.tone-3 strong {
  color: #8eb8ff;
}

.room-chat-list li.tone-4 strong {
  color: #c69cff;
}

.room-chat-list li.tone-5 strong {
  color: #76d36b;
}

.room-chat-list li.empty {
  justify-self: stretch;
  max-width: none;
  align-self: center;
  color: #b7bec9;
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

.room-chat-list li.system {
  justify-self: center;
  max-width: 94%;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.16);
  text-align: center;
}

.room-chat-list li.system span {
  display: inline-block;
  padding: 0;
  border: 0;
  background: transparent;
  color: #fff4c2;
  font-size: 12px;
  font-weight: 900;
}

.room-chat-list li.system.result {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.room-chat-list li.system .my-result {
  padding: 3px 7px;
  border-radius: 8px;
  background: rgba(247, 212, 74, 0.22);
  border: 1px solid rgba(247, 212, 74, 0.42);
  color: #fff8cf;
}

.room-chat-list li.system .system-divider {
  color: rgba(255, 244, 194, 0.55);
}

.room-chat-list strong {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  width: fit-content;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: #9ff0db;
  font-size: 11px;
  font-weight: 950;
}

.room-chat-list li.other strong::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 10px currentColor;
}

.room-chat-list li.me strong {
  justify-self: end;
  background: rgba(159, 240, 219, 0.14);
  color: #ffffff;
}

.room-chat-list span {
  display: block;
  padding: 7px 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  overflow-wrap: anywhere;
  color: #eef4ff;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.35;
}

.room-chat-list li.me span {
  background: rgba(159, 240, 219, 0.24);
  border-color: rgba(159, 240, 219, 0.28);
}

.room-chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 66px;
  align-items: center;
  gap: 7px;
}

.room-chat-form[hidden] {
  display: none;
}

.room-chat-form input {
  min-width: 0;
  min-height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.22);
  padding: 0 10px;
  color: #fffaf0;
  font: inherit;
  font-weight: 800;
}

.room-chat-form input:focus {
  outline: 2px solid rgba(159, 240, 219, 0.7);
  outline-offset: 2px;
}

.room-chat-form button {
  min-height: 38px;
  padding: 0 10px;
  background: rgba(69, 198, 168, 0.22);
  color: #9ff0db;
  border: 1px solid rgba(159, 240, 219, 0.36);
  box-shadow: none;
}

.room-modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 18px;
}

.room-modal[aria-hidden="true"] {
  display: none;
}

.room-modal-backdrop {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 22%, rgba(159, 240, 219, 0.24), transparent 34%),
    rgba(6, 10, 15, 0.74);
  backdrop-filter: blur(8px);
}

.room-modal-panel {
  position: relative;
  width: min(100%, 430px);
  border-radius: 8px;
  padding: 16px;
  background: #202832;
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.5), 0 6px 0 #111820;
}

.room-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.room-modal-head strong {
  color: #9ff0db;
  font-size: 22px;
  font-weight: 1000;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.26);
}

.room-modal-close,
.room-modal-secondary {
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  padding: 0 12px;
  background: #2f3845;
  color: #eef4ff;
  font-weight: 950;
  box-shadow: 0 4px 0 #161c24;
}

.room-modal-copy {
  margin: 0;
  color: #dce7ef;
  font-size: 14px;
  font-weight: 850;
}

.room-modal-error {
  margin: -2px 0 0;
  color: #ffb4a8;
  font-size: 13px;
  font-weight: 900;
}

.room-modal-error[hidden] {
  display: none;
}

.room-modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.invite-share {
  background: rgba(159, 240, 219, 0.18);
  color: #9ff0db;
  border: 1px solid rgba(159, 240, 219, 0.34);
  box-shadow: none;
}

.room-leave {
  background: rgba(238, 90, 90, 0.16);
  color: #ffb4a8;
  border: 1px solid rgba(238, 90, 90, 0.32);
  box-shadow: none;
}

.room-leave:active {
  transform: none;
  box-shadow: none;
}

.invite-share[hidden],
.room-leave[hidden] {
  display: none;
}

.match-prompt {
  position: absolute;
  left: 50%;
  bottom: min(330px, calc(28vw + 146px));
  z-index: 7;
  transform: translateX(-50%);
  display: grid;
  justify-items: center;
  gap: 6px;
  min-width: min(72vw, 260px);
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(15, 18, 23, 0.68);
  border: 1px solid rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(8px);
  pointer-events: none;
}

.match-prompt[hidden] {
  display: none;
}

.match-prompt p {
  display: none;
}

.match-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
  pointer-events: auto;
}

.match-start-center,
.match-accept,
.match-cancel {
  min-height: 38px;
  min-width: 82px;
  padding: 0 11px;
  font-size: 13px;
  box-shadow: none;
}

.match-start-center {
  background: #8eb8ff;
  color: #0d1d3a;
}

.match-accept {
  background: #45c6a8;
  color: #071f1a;
}

.match-cancel {
  background: #2f3845;
  color: #eef4ff;
}

.invite-share:active,
.room-chat-form button:active,
.match-start-center:active,
.match-accept:active,
.match-cancel:active {
  transform: none;
  box-shadow: none;
}

.match-start-center[hidden],
.match-accept[hidden],
.match-cancel[hidden] {
  display: none;
}

.player-list {
  min-height: 44px;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 7px;
  list-style: none;
}

.player-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 54px auto;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 7px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.player-list li.me {
  background: rgba(69, 198, 168, 0.16);
  border-color: rgba(69, 198, 168, 0.34);
}

.player-list li.empty {
  display: block;
  color: #b7bec9;
  font-size: 13px;
  font-weight: 800;
}

.player-list span {
  min-width: 0;
  overflow: hidden;
  color: #eef4ff;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-list small {
  color: #9ff0db;
  font-size: 12px;
  font-weight: 900;
  text-align: right;
}

.player-list strong {
  color: #ffffff;
  font-size: 18px;
  text-align: right;
}

.score-dialog {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(12, 15, 20, 0.66);
  backdrop-filter: blur(8px);
}

.score-dialog[aria-hidden="true"] {
  display: none;
}

.score-form {
  width: min(92vw, 360px);
  display: grid;
  gap: 12px;
  padding: 22px;
  border-radius: 8px;
  background:
    radial-gradient(circle at 18% 12%, rgba(255, 255, 255, 0.8), transparent 42px),
    linear-gradient(145deg, #fff6a8, #ffbf6f 52%, #ff7a68);
  color: #381408;
  box-shadow: 0 18px 0 rgba(126, 46, 36, 0.42), 0 28px 58px rgba(0, 0, 0, 0.38);
}

.score-form > span,
.score-form label {
  color: #fffaf0;
  font-weight: 1000;
  text-shadow: 0 2px 0 rgba(126, 46, 36, 0.45);
}

.score-form > strong {
  color: #ffffff;
  font-size: 42px;
  text-shadow: 0 4px 0 #9d2e24;
}

.nickname-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.nickname-row input {
  min-width: 0;
  min-height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 8px;
  background: rgba(39, 23, 20, 0.42);
  padding: 0 12px;
  color: #fffaf0;
  font: inherit;
  font-weight: 800;
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.16);
}

.nickname-row input:focus {
  outline: 2px solid rgba(255, 255, 255, 0.78);
  outline-offset: 2px;
}

.nickname-row input::selection {
  background: rgba(255, 255, 255, 0.32);
}

@media (max-width: 540px) {
  body {
    align-items: start;
  }

  .game-shell {
    width: 100%;
    max-width: none;
    gap: 8px;
    padding: 6px 0 8px;
  }

  .topbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    padding: 8px;
    margin: 0;
    border-left: 0;
    border-right: 0;
    border-radius: 0;
  }

  .score-card,
  .opponent-score-card,
  .time-card {
    min-height: 58px;
  }

  .score-card,
  .opponent-score-card {
    padding: 8px 10px 8px 46px;
  }

  .score-card {
    background:
      radial-gradient(circle at 20px 27px, #fff6a8 0 6px, #f7d44a 7px 16px, #b4871d 17px 20px, transparent 21px),
      linear-gradient(145deg, rgba(255, 230, 106, 0.28), rgba(255, 132, 89, 0.2));
  }

  .opponent-score-card {
    background:
      radial-gradient(circle at 20px 27px, #d7f3ff 0 6px, #58a6ff 7px 16px, #2869b8 17px 20px, transparent 21px),
      linear-gradient(145deg, rgba(88, 166, 255, 0.3), rgba(69, 198, 168, 0.18));
  }

  .score-card::after,
  .opponent-score-card::after {
    left: 24px;
    top: 15px;
    height: 22px;
  }

  .time-card {
    padding: 8px 10px;
  }

  .time-head {
    margin-bottom: 8px;
  }

  .time-track {
    height: 12px;
  }

  .duel-record {
    margin: 0;
    border-left: 0;
    border-right: 0;
    border-radius: 0;
    min-height: 28px;
    padding: 6px 7px;
    font-size: 12px;
    gap: 5px;
  }

  .duel-player {
    padding: 5px 7px;
    gap: 3px;
  }

  .duel-player strong {
    max-width: 76px;
    font-size: 12px;
  }

  .duel-player span {
    font-size: 11px;
  }

  .duel-player em {
    min-height: 16px;
    padding: 0 5px;
    font-size: 9px;
  }

  .duel-vs {
    min-width: 30px;
    height: 25px;
    font-size: 11px;
  }

  .stage-wrap {
    min-height: 0;
    width: 100%;
    border-left: 0;
    border-right: 0;
    border-radius: 0;
  }

  #stage {
    width: 100%;
    max-width: none;
    min-width: 0;
  }

  .overlay {
    gap: 10px;
    padding: 16px;
  }

  .overlay h1 {
    font-size: clamp(32px, 10vw, 46px);
  }

  .overlay p {
    font-size: 14px;
  }

  .network-panel,
  .leaderboard {
    gap: 8px;
    margin: 0;
    padding: 10px;
    border-left: 0;
    border-right: 0;
    border-radius: 0;
  }

  .network-head strong,
  .leaderboard-head strong {
    font-size: 17px;
  }

  .network-head span,
  .leaderboard-head span {
    font-size: 12px;
  }

  .network-form {
    grid-template-columns: 1fr;
  }

  .network-form.nickname-only {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .room-lobby-actions {
    grid-template-columns: 1fr;
  }

  .room-create-grid {
    grid-template-columns: 1fr;
  }

  button,
  .network-form input,
  .room-create-form input,
  .room-create-form select {
    min-height: 38px;
  }

  .room-list,
  .leaderboard-list {
    max-height: 112px;
    overflow: auto;
    overscroll-behavior: contain;
  }

  .leaderboard {
    max-height: 212px;
    overflow: hidden;
  }

  .room-list li,
  .leaderboard-list li {
    min-height: 34px;
    padding: 6px 8px;
  }

  .leaderboard-list {
    gap: 5px;
  }

  strong {
    font-size: 24px;
  }
}

@media (max-width: 380px) {
  .game-shell {
    padding: 4px 0 6px;
  }

  #stage {
    width: 100%;
  }

  .match-prompt {
    min-width: min(84vw, 240px);
    top: auto;
    bottom: min(310px, calc(28vw + 140px));
  }

  .match-start-center,
  .match-accept,
  .match-cancel {
    min-width: 88px;
    min-height: 40px;
    padding: 0 10px;
    font-size: 14px;
  }
}

@keyframes combo-burst {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.5) rotate(-12deg);
  }

  18% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.16) rotate(4deg);
  }

  58% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1) rotate(-2deg);
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -62%) scale(0.92) rotate(3deg);
  }
}

@keyframes attack-flash {
  0% {
    opacity: 0;
    background: rgba(238, 90, 90, 0);
    transform: scale(0.96);
  }

  18% {
    opacity: 1;
    background: rgba(238, 90, 90, 0.38);
    transform: scale(1.04);
  }

  62% {
    opacity: 1;
    background: rgba(238, 90, 90, 0.18);
    transform: scale(1);
  }

  100% {
    opacity: 0;
    background: rgba(238, 90, 90, 0);
    transform: translateY(-18px) scale(0.98);
  }
}

@keyframes board-hit-shake {
  0%,
  100% {
    transform: translate(0, 0);
  }

  20% {
    transform: translate(-8px, 4px);
  }

  40% {
    transform: translate(7px, -3px);
  }

  60% {
    transform: translate(-5px, -2px);
  }

  80% {
    transform: translate(4px, 3px);
  }
}

@keyframes time-pause-pulse {
  from {
    box-shadow: 0 0 0 rgba(88, 166, 255, 0);
  }

  to {
    box-shadow:
      0 0 0 2px rgba(88, 166, 255, 0.38),
      0 0 24px rgba(88, 166, 255, 0.42);
  }
}

@keyframes time-bonus-pop {
  0% {
    transform: scale(1);
  }

  38% {
    transform: scale(1.04);
    box-shadow:
      0 0 0 2px rgba(69, 198, 168, 0.46),
      0 0 28px rgba(69, 198, 168, 0.48);
  }

  100% {
    transform: scale(1);
  }
}
