:root {
  color-scheme: dark;
  --bg: #121416;
  --panel: #191d21;
  --panel-strong: #20262b;
  --line: rgba(255, 255, 255, 0.14);
  --text: #f3f6f7;
  --muted: #aab4b8;
  --accent: #ffe35a;
  --accent-strong: #f4c41f;
  --danger: #ff6b62;
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  font-family: "Pretendard", "Noto Sans KR", "Apple SD Gothic Neo", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

button {
  border: 0;
  font: inherit;
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  height: 100vh;
  min-height: 680px;
  transition: grid-template-columns 260ms ease;
}

.viewer-panel {
  position: relative;
  min-width: 0;
  background: #0c0f11;
}

.roadview,
.guess-map {
  width: 100%;
  height: 100%;
}

.topbar {
  position: absolute;
  top: 20px;
  left: 20px;
  right: 20px;
  z-index: 3;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  pointer-events: none;
}

.topbar h1,
.panel-header h2 {
  margin: 2px 0 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: clamp(28px, 4vw, 54px);
  line-height: 1;
  text-shadow: 0 3px 18px rgba(0, 0, 0, 0.5);
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(86px, 1fr));
  gap: 8px;
}

.stats div {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(18, 20, 22, 0.78);
  box-shadow: var(--shadow);
}

.stats span,
.result-box span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

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

.loading,
.message {
  position: absolute;
  left: 50%;
  z-index: 4;
  transform: translateX(-50%);
  border-radius: 8px;
  background: rgba(18, 20, 22, 0.86);
  box-shadow: var(--shadow);
}

.loading {
  top: 50%;
  padding: 14px 18px;
  transform: translate(-50%, -50%);
  color: var(--accent);
  font-weight: 800;
}

.loading.is-hidden {
  display: none;
}

.message {
  bottom: 24px;
  display: none;
  max-width: min(620px, calc(100% - 40px));
  padding: 12px 14px;
  color: var(--text);
  text-align: center;
}

.message.is-visible {
  display: block;
}

.message.is-error {
  color: var(--danger);
}

.game-panel {
  display: grid;
  grid-template-rows: auto minmax(250px, 1fr) auto auto minmax(120px, auto);
  gap: 14px;
  min-width: 0;
  padding: 18px;
  border-left: 1px solid var(--line);
  background: var(--panel);
  transition: box-shadow 260ms ease;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.panel-header h2 {
  font-size: 22px;
  line-height: 1.2;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  color: var(--text);
  font-size: 23px;
}

.guess-map {
  overflow: hidden;
  min-height: 250px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #dfe5e5;
}

.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.primary-button,
.secondary-button {
  min-height: 46px;
  border-radius: 8px;
  font-weight: 900;
}

.primary-button {
  background: var(--accent);
  color: #171300;
}

.secondary-button {
  border: 1px solid var(--line);
  background: var(--panel-strong);
  color: var(--text);
}

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

.result-box {
  min-height: 118px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
}

.result-box strong {
  display: block;
  margin-top: 6px;
  font-size: 24px;
  line-height: 1.2;
}

.result-box p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.round-list {
  display: grid;
  align-content: start;
  gap: 8px;
  overflow: auto;
  min-height: 120px;
}

.round-item,
.empty-rounds {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.round-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 3px 8px;
  padding: 10px;
}

.round-item span {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.round-item strong {
  font-size: 13px;
}

.round-item em {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.empty-rounds {
  display: grid;
  min-height: 72px;
  place-items: center;
  padding: 12px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.setup-needed .roadview,
.setup-needed .guess-map {
  opacity: 0.25;
}

@media (min-width: 1000px) {
  .app-shell:has(.game-panel:hover),
  .app-shell.is-guess-expanded {
    grid-template-columns: minmax(280px, 28vw) minmax(720px, 72vw);
  }

  .app-shell:has(.game-panel:hover) .game-panel,
  .app-shell.is-guess-expanded .game-panel {
    box-shadow: -24px 0 48px rgba(0, 0, 0, 0.34);
  }
}

@media (max-width: 920px) {
  body {
    overflow: auto;
  }

  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(460px, 62vh) auto;
    height: auto;
    min-height: 100vh;
  }

  .game-panel {
    grid-template-rows: auto 340px auto auto auto;
    border-top: 1px solid var(--line);
    border-left: 0;
  }
}

@media (max-width: 560px) {
  .app-shell {
    grid-template-rows: minmax(420px, 58vh) auto;
  }

  .topbar {
    top: 14px;
    left: 14px;
    right: 14px;
    display: grid;
  }

  .stats {
    width: 100%;
  }

  .game-panel {
    padding: 14px;
  }

  .controls {
    grid-template-columns: 1fr;
  }
}
