:root {
  color-scheme: light;
  --ink: #083b43;
  --muted: #4f6e73;
  --blue: #0a7fd8;
  --blue-deep: #065d9f;
  --green: #2bb36b;
  --green-deep: #12804e;
  --white: #ffffff;
  --line: rgba(8, 59, 67, 0.16);
  --shadow: 0 18px 45px rgba(3, 50, 74, 0.2);
}

* {
  box-sizing: border-box;
}

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

body {
  display: grid;
  place-items: center;
  overflow-x: hidden;
  background:
    linear-gradient(135deg, rgba(23, 168, 91, 0.95), rgba(8, 137, 217, 0.92)),
    linear-gradient(45deg, #eafff3, #eaf6ff);
  color: var(--ink);
  font-family:
    "Malgun Gothic",
    "Apple SD Gothic Neo",
    system-ui,
    sans-serif;
}

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

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 290px;
  gap: 18px;
  width: min(1180px, calc(100vw - 28px));
  min-height: min(760px, calc(100vh - 28px));
  padding: 18px;
}

.play-area,
.rank-panel {
  border: 1px solid rgba(255, 255, 255, 0.48);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.play-area {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 18px 12px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--blue-deep);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.05;
}

h1 {
  font-size: clamp(1.55rem, 3.4vw, 2.75rem);
}

h2 {
  font-size: 1.45rem;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.primary-button,
.ghost-button {
  min-width: 78px;
  min-height: 42px;
  border-radius: 8px;
  padding: 0 18px;
  font-weight: 900;
}

.primary-button {
  background: var(--ink);
  color: var(--white);
}

.ghost-button {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.58;
}

.stage-wrap {
  display: grid;
  min-height: 0;
  padding: 0 18px 18px;
}

#gameCanvas {
  width: 100%;
  height: 100%;
  min-height: 540px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  background: #0f8a8f;
  box-shadow: inset 0 0 0 1px rgba(8, 59, 67, 0.18);
}

.rank-panel {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 0;
  padding: 18px;
}

.panel-head {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.rank-list {
  display: grid;
  align-content: start;
  gap: 10px;
  margin: 16px 0;
  padding: 0;
  list-style: none;
}

.rank-list li {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.rank-num {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  margin-left: 10px;
  border-radius: 50%;
  background: var(--green);
  color: var(--white);
  font-weight: 900;
}

.rank-name {
  overflow: hidden;
  padding: 0 12px 0 6px;
  font-size: 1.08rem;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-list li.finished {
  border-color: rgba(18, 128, 78, 0.5);
  background: linear-gradient(90deg, rgba(43, 179, 107, 0.2), rgba(10, 127, 216, 0.12));
}

.status-text {
  min-height: 46px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
  color: var(--muted);
  font-weight: 800;
}

@media (max-width: 860px) {
  body {
    place-items: stretch;
  }

  .app-shell {
    grid-template-columns: 1fr;
    width: 100%;
    min-height: 100vh;
    padding: 12px;
  }

  .topbar {
    align-items: flex-start;
  }

  .rank-panel {
    min-height: 280px;
  }

  #gameCanvas {
    min-height: 520px;
  }
}

@media (max-width: 560px) {
  .topbar {
    display: grid;
  }

  .controls {
    justify-content: stretch;
  }

  .primary-button,
  .ghost-button {
    flex: 1 1 130px;
  }
}
