:root {
  color-scheme: dark;
  font-family: "Trebuchet MS", "Hiragino Sans", "Yu Gothic", sans-serif;
  --bg: #17181c;
  --surface: #262930;
  --surface-2: #2f333b;
  --surface-3: #3b414b;
  --line: #444b56;
  --text: #f4f0e8;
  --muted: #b7b2a7;
  --brand: #d87342;
  --brand-2: #f2b84b;
  --green: #2f9e62;
  --red: #d25757;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at top right, rgba(242, 184, 75, 0.12), transparent 32%),
    linear-gradient(180deg, rgba(9, 11, 15, 0.2), rgba(9, 11, 15, 0.92)),
    url("./image/island-bg.png") center / cover fixed,
    var(--bg);
}

button, input, select { font: inherit; }

button {
  border: 0;
  border-radius: 8px;
  padding: 10px 14px;
  color: #fff8ef;
  background: var(--brand);
  cursor: pointer;
  font-weight: 700;
}

button.secondary { background: var(--surface-3); }
button.green { background: var(--green); }
button.danger, button.red { background: var(--red); }
button:disabled { cursor: not-allowed; opacity: 0.5; }

input, select {
  width: 100%;
  border: 1px solid #1c1f24;
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  background: #171a1f;
}

label { display: grid; gap: 6px; font-size: 14px; }
.shell { min-height: 100vh; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 18px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.24);
  background: rgba(23, 24, 28, 0.86);
  backdrop-filter: blur(10px);
}

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

.activity-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #2d170f;
  font-weight: 900;
}

.title strong, h1, h2, h3 { margin: 0; }
.title span, .muted, .eyebrow, .presence { color: var(--muted); }

.presence {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--green);
}

.app {
  width: calc(100vw - 8px);
  margin: 0 auto;
  padding: 6px 0 12px;
}

.hero, .card {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  background: rgba(28, 31, 37, 0.82);
  backdrop-filter: blur(10px);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.24);
}

.hero {
  display: grid;
  grid-template-columns: 1.2fr auto;
  gap: 12px;
  align-items: end;
  min-height: 150px;
  padding: 12px 14px;
  background:
    linear-gradient(90deg, rgba(23, 24, 28, 0.95), rgba(23, 24, 28, 0.58), rgba(23, 24, 28, 0.18)),
    url("./image/island-bg.png") center / cover;
}

.hero-copy h1 {
  font-size: clamp(44px, 8vw, 88px);
  line-height: 0.92;
}

.hero-copy p:last-child { max-width: 100%; margin: 8px 0 0; }

.eyebrow {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.hero-actions, .inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.view { margin-top: 10px; }
.view-head { margin-bottom: 10px; }
.card { padding: 10px; }

.grid {
  display: grid;
  gap: 10px;
}

.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.room-layout { grid-template-columns: minmax(0, 2.15fr) minmax(330px, 0.85fr); }
.inner-grid { margin-top: 10px; }

.panel {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.03);
}

.form-grid, .stack { display: grid; gap: 8px; }
.stack.compact { gap: 6px; }
.full { grid-column: 1 / -1; }
.room-list { display: grid; gap: 10px; }

.room-item,
.player-card,
.stat,
.item-card,
.setting-row,
.vote-row {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.12);
}

.room-item,
.player-card,
.setting-row,
.vote-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

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

.stats {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
  width: 100%;
  min-width: 0;
}

.stat span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.stat strong {
  display: block;
  margin-top: 4px;
  font-size: 22px;
  line-height: 1.05;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat strong.phase-value {
  font-size: clamp(14px, 1.15vw, 22px);
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 4px 9px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 12px;
}

.tag.owner { background: rgba(242, 184, 75, 0.2); color: #ffe2a4; }
.tag.self { background: rgba(47, 158, 98, 0.2); color: #bcf0d2; }
.tag.dead { background: rgba(210, 87, 87, 0.2); color: #ffb6b6; }
.tag.warn { background: rgba(242, 184, 75, 0.2); color: #ffe4a1; }

.log {
  margin: 0;
  padding-left: 20px;
  max-height: 58vh;
  overflow: auto;
}

.log li { margin: 8px 0; color: var(--muted); }

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.check input { width: auto; }
.full-width { width: 100%; }
.hidden { display: none !important; }

.banner {
  border: 1px solid rgba(242, 184, 75, 0.35);
  border-radius: 10px;
  padding: 12px;
  background: rgba(242, 184, 75, 0.1);
  color: #ffe5b0;
}

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

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 10, 14, 0.74);
  backdrop-filter: blur(8px);
}

.modal-dialog {
  position: relative;
  z-index: 1;
  width: min(720px, calc(100vw - 12px));
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 16px;
  padding: 14px;
  background: rgba(28, 31, 37, 0.96);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
}

.modal-dialog-wide {
  width: min(980px, calc(100vw - 12px));
}

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

.modal-close {
  flex: 0 0 auto;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.choice-card,
.item-icon-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
}

.choice-card {
  padding: 14px 10px;
  text-align: center;
}

.choice-card strong {
  display: block;
  font-size: 18px;
}

.choice-card span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.item-modal-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.8fr);
  gap: 10px;
  align-items: start;
}

.item-icon-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.item-icon-card {
  display: grid;
  gap: 6px;
  justify-items: center;
  padding: 12px 8px;
  cursor: pointer;
  text-align: center;
}

.item-icon-card.active {
  border-color: rgba(242, 184, 75, 0.6);
  background: rgba(242, 184, 75, 0.12);
}

.item-icon-card.empty {
  opacity: 0.55;
  cursor: default;
}

.item-icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 12px;
  font-size: 24px;
  background: rgba(255, 255, 255, 0.08);
}

.item-icon-card strong {
  font-size: 14px;
  line-height: 1.25;
}

.item-icon-card span {
  color: var(--muted);
  font-size: 12px;
}

.item-modal-side {
  display: grid;
  gap: 10px;
  min-height: 100%;
}

.match-check {
  align-self: end;
  justify-self: start;
  margin-top: auto;
}

@media (max-width: 1080px) {
  .room-layout,
  .grid.two {
    grid-template-columns: 1fr 1fr;
  }

  .room-layout { grid-template-columns: 1fr; }
  .item-modal-layout { grid-template-columns: 1fr; }
  .item-icon-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .app { width: min(100vw - 20px, 100%); }

  .hero,
  .grid.two,
  .room-item,
  .player-card,
  .setting-row,
  .vote-row,
  .room-header,
  .topbar {
    grid-template-columns: 1fr;
  }

  .hero,
  .topbar,
  .room-header,
  .modal-head {
    display: grid;
  }

  .hero-actions,
  .inline-actions {
    flex-direction: column;
  }

  .choice-grid,
  .item-icon-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stats {
    grid-template-columns: repeat(8, minmax(0, 1fr));
    width: 100%;
    overflow-x: auto;
  }
}
