:root {
  --ink: #172036;
  --muted: #69748a;
  --panel: rgba(255, 255, 255, 0.92);
  --line: rgba(23, 32, 54, 0.16);
  --red: #e04852;
  --yellow: #f4df42;
  --green: #80ca62;
  --blue: #2f6ec8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Segoe UI", "Malgun Gothic", system-ui, sans-serif;
  background:
    linear-gradient(180deg, rgba(82, 176, 210, 0.16), rgba(255, 218, 88, 0.22)),
    repeating-linear-gradient(90deg, #f2dcc2 0 108px, #e8cba8 108px 112px, #f7e7d3 112px 216px);
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 38px;
  border: 1px solid rgba(23, 32, 54, 0.18);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  box-shadow: 0 2px 0 rgba(23, 32, 54, 0.12);
  cursor: pointer;
}

button:hover {
  transform: translateY(-1px);
}

button:active {
  transform: translateY(1px);
  box-shadow: none;
}

input {
  min-height: 38px;
  width: 96px;
  border: 1px solid rgba(23, 32, 54, 0.18);
  border-radius: 8px;
  padding: 0 10px;
  text-transform: uppercase;
}

select {
  min-height: 38px;
  border: 1px solid rgba(23, 32, 54, 0.18);
  border-radius: 8px;
  padding: 0 8px;
  color: var(--ink);
  background: #fff;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px;
}

.game-stage {
  position: relative;
  width: min(1180px, 100%);
  aspect-ratio: 16 / 10;
  min-height: 620px;
  overflow: hidden;
  border: 8px solid #293142;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0.22)),
    repeating-linear-gradient(90deg, var(--stage-wall-b, #d6b28b) 0 6px, var(--stage-wall-a, #f6eadc) 6px 110px, var(--stage-wall-c, #c99d72) 110px 114px);
  box-shadow: 0 18px 50px rgba(23, 32, 54, 0.25);
}

#gameCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.top-bar,
.score-panel,
.online-panel,
.lobby-panel,
.message {
  position: absolute;
  z-index: 2;
}

.top-bar {
  top: 16px;
  left: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  pointer-events: none;
}

.brand,
.controls,
.score-panel,
.online-panel,
.lobby-panel,
.message {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  backdrop-filter: blur(10px);
}

.brand,
.controls {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  pointer-events: auto;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: #fff;
  font-weight: 900;
  background: conic-gradient(var(--red), var(--yellow), var(--green), var(--blue), var(--red));
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 15px;
}

.brand div span {
  color: var(--muted);
  font-size: 12px;
}

.controls button {
  padding: 0 12px;
}

#soundButton {
  width: 40px;
  padding: 0;
  font-size: 20px;
  font-weight: 800;
}

.score-panel {
  top: 94px;
  right: 16px;
  width: 226px;
  padding: 12px;
  pointer-events: auto;
}

.round-banner,
.score-row,
.throw-info,
.reward-row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 42px;
  border-radius: 8px;
  padding: 0 12px;
  margin-bottom: 8px;
  background: rgba(255, 255, 255, 0.68);
}

.round-banner {
  min-height: 38px;
  color: #fff;
  background: linear-gradient(90deg, #293142, var(--stage-accent, #e04852));
}

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

.score-row::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 9px;
  bottom: 9px;
  width: 6px;
  border-radius: 999px;
  background: var(--ball-color, #1245b9);
}

.score-row span {
  padding-left: 11px;
}

.score-row.active {
  outline: 3px solid rgba(244, 201, 67, 0.72);
}

.score-row strong,
.throw-info strong,
.reward-row strong {
  font-size: 24px;
}

.reward-row strong {
  font-size: 18px;
}

.mission {
  min-height: 34px;
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 8px;
  color: #293142;
  font-size: 13px;
  font-weight: 800;
  background: rgba(244, 223, 66, 0.36);
}

.item-panel {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin-bottom: 8px;
}

.item-panel button {
  min-height: 32px;
  padding: 0 4px;
  font-size: 11px;
  font-weight: 800;
}

.item-panel button.selected {
  color: #fff;
  background: #293142;
}

.item-panel button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.history {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 32px;
}

.history span {
  min-width: 36px;
  border-radius: 999px;
  padding: 5px 8px;
  text-align: center;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  background: #293142;
}

.online-panel {
  left: 16px;
  bottom: 16px;
  width: min(410px, calc(100% - 32px));
  padding: 10px;
}

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

.online-actions button {
  padding: 0 12px;
}

#onlineHint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.invite-link {
  margin-top: 8px;
  min-height: 32px;
  border-radius: 8px;
  padding: 7px 9px;
  color: #293142;
  font-size: 11px;
  line-height: 1.35;
  word-break: break-all;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(23, 32, 54, 0.12);
}

.lobby-panel {
  left: 16px;
  top: 182px;
  width: 286px;
  max-height: 356px;
  padding: 10px;
  pointer-events: auto;
  overflow: hidden;
}

.lobby-tabs {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 5px;
  margin-bottom: 8px;
}

.lobby-tabs button {
  min-height: 30px;
  padding: 0 4px;
  font-size: 11px;
  font-weight: 800;
  box-shadow: none;
}

.lobby-tabs button.active {
  color: #fff;
  background: #293142;
}

.challenge-notice {
  display: none;
  margin-bottom: 8px;
  border-radius: 8px;
  padding: 8px;
  color: #fff;
  background: linear-gradient(90deg, #293142, var(--red));
}

.challenge-notice.active {
  display: block;
}

.challenge-notice div {
  display: flex;
  gap: 6px;
  margin-top: 7px;
}

.challenge-notice button {
  flex: 1;
  min-height: 30px;
}

.lobby-content {
  max-height: 278px;
  overflow: auto;
  padding-right: 2px;
}

.lobby-content h2 {
  margin: 0 0 8px;
  font-size: 14px;
}

.lobby-empty {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.lobby-user,
.shop-card,
.mission-card,
.profile-grid {
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(23, 32, 54, 0.1);
}

.lobby-user,
.shop-card,
.mission-card {
  margin-bottom: 7px;
  padding: 8px;
}

.lobby-user,
.shop-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.lobby-user strong,
.shop-card strong,
.mission-card strong {
  display: block;
  font-size: 12px;
}

.lobby-user span,
.shop-card small,
.mission-card span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.lobby-user button,
.shop-card button {
  min-width: 56px;
  min-height: 31px;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 800;
}

.mission-card.active {
  outline: 2px solid rgba(244, 201, 67, 0.72);
}

.profile-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 12px;
  padding: 10px;
  font-size: 12px;
}

.profile-grid span {
  color: var(--muted);
}

.help-list p {
  margin: 0 0 8px;
  border-radius: 8px;
  padding: 8px;
  font-size: 12px;
  line-height: 1.45;
  background: rgba(255, 255, 255, 0.72);
}

.message {
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  width: min(410px, calc(100% - 32px));
  padding: 11px 14px;
  text-align: center;
  font-weight: 800;
  pointer-events: none;
}

@media (max-width: 760px) {
  .app-shell {
    padding: 0;
  }

  .game-stage {
    width: 100vw;
    min-height: 100vh;
    border: 0;
    border-radius: 0;
    aspect-ratio: auto;
  }

  .top-bar {
    align-items: flex-start;
  }

  .brand strong {
    font-size: 13px;
  }

  .controls {
    flex-wrap: wrap;
    justify-content: flex-end;
    max-width: 172px;
  }

  .controls button {
    min-height: 34px;
    padding: 0 8px;
    font-size: 12px;
  }

  .controls select {
    min-height: 34px;
    max-width: 74px;
    padding: 0 5px;
    font-size: 12px;
  }

  .score-panel {
    top: auto;
    left: 10px;
    right: 10px;
    bottom: 78px;
    width: auto;
    display: grid;
    grid-template-columns: 1fr 1fr 0.82fr;
    gap: 6px;
    padding: 8px;
  }

  .round-banner,
  .score-row,
  .throw-info,
  .reward-row {
    min-height: 30px;
    margin-bottom: 0;
    padding: 0 8px;
    font-size: 11px;
  }

  .score-row strong,
  .throw-info strong,
  .reward-row strong {
    font-size: 17px;
  }

  .round-banner {
    grid-column: 1 / 2;
  }

  #playerOneRow {
    grid-column: 2 / 3;
  }

  #playerTwoRow {
    grid-column: 3 / 4;
  }

  .reward-row,
  .throw-info {
    min-height: 28px;
  }

  .history {
    display: none;
  }

  .round-banner strong,
  .mission {
    font-size: 11px;
  }

  .mission {
    grid-column: 1 / 4;
    min-height: 28px;
    padding: 7px 8px;
    margin-bottom: 0;
  }

  .item-panel {
    grid-column: 1 / 4;
    margin-bottom: 0;
  }

  .item-panel button {
    min-height: 28px;
    font-size: 11px;
  }

  .online-panel {
    top: 142px;
    left: 10px;
    right: 10px;
    bottom: auto;
    width: auto;
    padding: 8px;
  }

  .online-actions {
    grid-template-columns: 0.9fr 1fr 0.72fr 0.95fr;
    gap: 5px;
  }

  .online-actions button,
  .online-actions input {
    min-height: 32px;
    padding: 0 6px;
    font-size: 11px;
  }

  #onlineHint,
  .invite-link {
    display: none;
  }

  .lobby-panel {
    top: auto;
    left: 10px;
    right: 10px;
    bottom: 204px;
    width: auto;
    max-height: 146px;
    padding: 8px;
  }

  .lobby-tabs {
    gap: 4px;
    margin-bottom: 6px;
  }

  .lobby-tabs button {
    min-height: 28px;
    font-size: 10px;
  }

  .lobby-content {
    max-height: 76px;
  }

  .lobby-content h2 {
    display: none;
  }

  .lobby-user,
  .shop-card,
  .mission-card {
    margin-bottom: 5px;
    padding: 6px;
  }

  .challenge-notice {
    padding: 6px;
    font-size: 12px;
  }

  .message {
    bottom: 12px;
    font-size: 13px;
    padding: 9px 12px;
  }
}
