:root {
  color-scheme: light;
  --ink: #18202a;
  --muted: #68717e;
  --line: #d9dee7;
  --panel: #ffffff;
  --bg: #eef2f6;
  --soft: #f7f8fb;
  --blue: #255c99;
  --green: #23885f;
  --red: #b84b47;
  --amber: #b7791f;
  --teal: #237b88;
  --shadow: 0 14px 36px rgba(25, 35, 55, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Segoe UI", "Noto Sans KR", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.app-shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 24px;
  border-right: 1px solid var(--line);
  background: #fbfcfe;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(145deg, var(--blue), var(--teal));
  font-weight: 800;
  box-shadow: inset -4px -5px 0 rgba(0, 0, 0, 0.12);
}

.brand h1,
.stage-header h2,
.log-panel h3,
.leader-panel h3 {
  margin: 0;
}

.brand h1 {
  font-size: 22px;
  line-height: 1.1;
}

.brand p,
.meta {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.field-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.login-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  gap: 8px;
}

.auth-status {
  min-height: 34px;
  margin: -8px 0 0;
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--soft);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.oauth-button {
  display: grid;
  min-height: 42px;
  place-items: center;
  border-radius: 8px;
  padding: 0 12px;
  background: #2d3745;
  color: #fff;
  font-weight: 750;
  text-align: center;
  text-decoration: none;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
}

.icon-button,
.primary-button,
.ghost-button,
.danger-button,
.choice-button {
  min-height: 42px;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 750;
}

.icon-button,
.primary-button {
  color: #fff;
  background: var(--blue);
}

.danger-button {
  color: #fff;
  background: var(--red);
}

.ghost-button,
.choice-button {
  color: var(--ink);
  background: #e9edf4;
}

.profile-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.profile-panel > div {
  min-height: 74px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--panel);
}

.profile-panel strong {
  display: block;
  margin-top: 4px;
  font-size: 26px;
}

.game-list {
  display: grid;
  gap: 8px;
}

.game-tab {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr);
  gap: 10px;
  min-height: 62px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: left;
  background: var(--panel);
}

.game-tab::before {
  content: "";
  align-self: stretch;
  border-radius: 99px;
  background: #a7b0bd;
}

.game-tab.active {
  border-color: rgba(37, 92, 153, 0.55);
  box-shadow: 0 0 0 3px rgba(37, 92, 153, 0.12);
}

.game-tab.active::before {
  background: var(--blue);
}

.game-tab strong,
.game-tab span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-tab span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.stage {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 16px;
  padding: 24px;
}

.stage-header {
  display: flex;
  min-height: 64px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.stage-header h2 {
  font-size: 28px;
}

.header-actions {
  display: flex;
  gap: 8px;
}

.surface {
  min-height: 430px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.room-panel {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfe;
}

.room-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.room-summary strong {
  display: block;
  margin-top: 3px;
  font-size: 18px;
}

.room-badges,
.room-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 8px;
  padding: 0 10px;
  background: #e9edf4;
  color: #2d3745;
  font-size: 13px;
  font-weight: 750;
}

.status-pill.idle {
  background: #e7f3ed;
  color: #1f5f42;
}

.status-pill.running {
  background: #fff2dd;
  color: #86520f;
}

.room-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(260px, auto);
  gap: 10px;
  align-items: stretch;
}

.room-list {
  min-height: 72px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--panel);
}

.room-list > div {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 7px;
}

.room-user {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 8px;
  padding: 0 9px;
  background: var(--soft);
  color: #2d3745;
  font-size: 13px;
  font-weight: 700;
}

.room-actions {
  align-content: center;
  justify-content: flex-end;
}

.bottom-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(260px, 0.9fr);
  gap: 16px;
}

.log-panel,
.leader-panel {
  min-height: 190px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: var(--panel);
}

.log-panel h3,
.leader-panel h3 {
  margin-bottom: 12px;
  font-size: 16px;
}

.log,
.leaderboard {
  display: grid;
  gap: 8px;
}

.log-entry,
.leader-row {
  min-height: 34px;
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--soft);
  color: #2d3745;
  font-size: 14px;
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.game-card {
  display: grid;
  gap: 16px;
}

.game-card h3 {
  margin: 0;
  font-size: 20px;
}

.muted {
  color: var(--muted);
}

.is-hidden {
  display: none !important;
}

.result-line {
  min-height: 40px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #eef5f0;
  color: #1f5f42;
}

.color-grid {
  --grid-size: 5;
  display: grid;
  grid-template-columns: repeat(var(--grid-size), minmax(0, 1fr));
  gap: 4px;
  width: min(100%, 520px);
  aspect-ratio: 1;
  padding: 8px;
  border-radius: 8px;
  background: #1e2733;
}

.color-cell {
  display: grid;
  min-width: 0;
  min-height: 0;
  place-items: center;
  border-radius: 5px;
  color: #fff;
  font-weight: 800;
  box-shadow: inset -2px -3px 0 rgba(0, 0, 0, 0.18);
}

.choice-row,
.answer-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.answer-row input {
  max-width: 360px;
}

.mask-board {
  display: grid;
  gap: 10px;
  max-width: 720px;
}

.music-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 34px;
}

.music-status strong {
  color: var(--blue);
}

.mask {
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #101722;
  color: #f3f6fa;
  font-family: "Consolas", "Courier New", monospace;
  font-size: 24px;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.pitch-keyboard,
.pitch-keyboard-empty {
  display: grid;
  gap: 14px;
  max-width: 760px;
}

.pitch-keyboard-empty {
  min-height: 120px;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--soft);
}

.octave-row {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  align-items: stretch;
  gap: 10px;
}

.octave-label {
  display: grid;
  min-height: 112px;
  place-items: center;
  border-radius: 8px;
  background: #1c2735;
  color: #fff;
  font-weight: 800;
}

.piano-octave {
  position: relative;
  min-height: 112px;
}

.white-keys {
  display: grid;
  grid-template-columns: repeat(7, minmax(38px, 1fr));
  height: 112px;
}

.piano-key {
  position: relative;
  border: 1px solid #c9d0da;
  font-weight: 800;
}

.white-key {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 10px;
  border-radius: 0 0 7px 7px;
  background: linear-gradient(180deg, #ffffff, #edf1f6);
  color: #1d2733;
  box-shadow: inset 0 -8px 0 rgba(25, 35, 55, 0.08);
}

.black-keys {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.black-key {
  position: absolute;
  top: 0;
  left: calc((100% / 7) * var(--key-left));
  z-index: 2;
  width: min(9%, 48px);
  height: 68px;
  transform: translateX(-50%);
  border-radius: 0 0 6px 6px;
  border-color: #111820;
  background: linear-gradient(180deg, #263343, #05080c);
  color: #fff;
  box-shadow: 0 6px 10px rgba(0, 0, 0, 0.24), inset 0 -8px 0 rgba(255, 255, 255, 0.06);
  pointer-events: auto;
}

.black-key span {
  display: block;
  transform: translateY(12px);
  font-size: 12px;
}

.gamble-grid {
  display: grid;
  grid-template-columns: minmax(260px, 0.8fr) minmax(320px, 1.2fr);
  gap: 18px;
}

.dice-scene {
  display: grid;
  min-height: 250px;
  place-items: center;
  border-radius: 8px;
  background: radial-gradient(circle at 35% 25%, #f9fbff, #cfd9e7 68%, #b5c0cf);
  perspective: 800px;
}

.die {
  display: grid;
  width: 112px;
  height: 112px;
  place-items: center;
  border-radius: 18px;
  color: #fff;
  background: linear-gradient(145deg, #2a6fb3, #173b66);
  box-shadow: 16px 22px 24px rgba(20, 35, 55, 0.28), inset -12px -16px 0 rgba(0, 0, 0, 0.18);
  font-size: 46px;
  font-weight: 900;
  transform: rotateX(18deg) rotateY(-25deg) rotateZ(6deg);
  transition: transform 360ms ease;
}

.die.roll {
  transform: rotateX(380deg) rotateY(310deg) rotateZ(16deg);
}

.slot-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 12px 0;
}

.mahjong-tile {
  display: flex;
  width: 58px;
  height: 88px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  place-items: center;
  border-radius: 8px;
  border: 1px solid #d4d7cf;
  background: linear-gradient(145deg, #fffdf5, #e6e0d1);
  box-shadow: 7px 10px 14px rgba(20, 35, 55, 0.16), inset -5px -7px 0 rgba(118, 112, 92, 0.12);
  font-family: "Noto Serif CJK KR", "Batang", "PMingLiU", serif;
  font-weight: 900;
}

.tile-number {
  color: #111820;
  font-size: 30px;
  line-height: 1;
}

.tile-man {
  color: #b62828;
  font-size: 26px;
  line-height: 1;
}

.tile-hatsu {
  color: #168044;
  font-size: 44px;
  line-height: 1;
}

.tile-unknown {
  color: var(--muted);
  font-family: inherit;
  font-size: 28px;
}

.word-status {
  display: grid;
  gap: 8px;
  max-width: 640px;
}

.current-word {
  display: inline-flex;
  align-items: center;
  min-height: 60px;
  width: fit-content;
  border-radius: 8px;
  padding: 0 18px;
  background: #17212e;
  color: #fff;
  font-size: 28px;
  font-weight: 850;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .game-list {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }

  .bottom-grid,
  .gamble-grid,
  .room-grid {
    grid-template-columns: 1fr;
  }

  .room-actions,
  .room-summary {
    justify-content: flex-start;
  }
}

@media (max-width: 560px) {
  .sidebar,
  .stage {
    padding: 16px;
  }

  .stage-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .room-summary {
    align-items: flex-start;
    flex-direction: column;
  }

  .surface {
    padding: 14px;
  }

  .octave-row {
    grid-template-columns: 1fr;
  }

  .octave-label {
    min-height: 40px;
  }
}
