:root {
  --bg: #f5f5f3;
  --panel: #ffffff;
  --panel-alt: #f2f2ef;
  --ink: #1a1a1a;
  --muted: #6b6b6b;
  --line: #d9d8d4;
  --accent: #e8b100;
  --accent-strong: #c68e00;
  --shadow: 0 10px 28px rgba(0, 0, 0, 0.08);
  --black: #111111;
  --white: #f4f4f4;
  --yellow: #f6d300;
  --danger: #c94040;
}

* {
  box-sizing: border-box;
}

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

body {
  display: flex;
  justify-content: center;
  padding: 20px 14px 40px;
}

button,
select {
  font: inherit;
}

.app-shell {
  width: min(100%, 520px);
}

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

.eyebrow {
  margin: 0 0 4px;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-size: 0.7rem;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(1.8rem, 6vw, 2.3rem);
}

h2, h3, h4 {
  margin: 0;
}

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

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 12px 14px 14px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.header-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.panel-header.compact {
  margin-bottom: 8px;
}

.card-row,
.guess-row {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  overflow-x: auto;
  justify-content: flex-start;
}

.card-row.small .card,
.guess-row.small .card {
  width: 42px;
  height: 58px;
  font-size: 1rem;
}

.card {
  position: relative;
  width: 54px;
  height: 76px;
  border-radius: 12px;
  border: 2px solid rgba(0,0,0,0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.2rem;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.3);
}

.card[data-hidden="true"] {
  color: transparent;
  background: #f6f6f4;
  border-style: dashed;
}

.card[data-hidden="true"]::before {
  content: "?";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 1.15rem;
}

.card.black {
  background: var(--black);
  color: white;
}

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

.card.yellow {
  background: var(--yellow);
  color: #5c4e00;
}

.card.placeholder {
  border-style: dashed;
  border-color: var(--line);
  background: #fafaf7;
  color: var(--muted);
  font-size: 1.2rem;
}

.opponent-grid,
.opponent-guess-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.opponent-block {
  background: var(--panel-alt);
  border-radius: 16px;
  border: 1px solid var(--line);
  padding: 10px 8px 12px;
}

.question-box {
  min-height: 70px;
  border-radius: 16px;
  background: var(--panel-alt);
  border: 1px dashed var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  font-size: 1.1rem;
  text-align: center;
}

.question-box:not(.empty) {
  border-style: solid;
  background: #fffdf2;
  border-color: rgba(230, 177, 0, 0.5);
}
 
.question-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}
 
.question-option {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-alt);
  color: var(--ink);
  padding: 10px 8px;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
  line-height: 1.3;
}
 
.question-option:hover {
  border-color: rgba(230, 177, 0, 0.7);
  background: #fffaf0;
}
 
.answer-box {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

.answer-label {
  min-height: 20px;
  margin-top: 8px;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 700;
}

.answer-history {
  margin-top: 20px;
  display: grid;
  gap: 6px;
}

.log-item {
  background: var(--panel-alt);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 7px 8px;
  font-size: 0.72rem;
}

.log-question {
  font-weight: 700;
  margin-bottom: 3px;
}

.empty-log {
  color: var(--muted);
  font-size: 0.72rem;
}

.answer-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--panel-alt);
}

.answer-row strong {
  font-size: 0.9rem;
}

.answer-row span {
  font-weight: 600;
}

button.primary,
button.secondary {
  border: none;
  border-radius: 12px;
  padding: 10px 12px;
  font-weight: 700;
  cursor: pointer;
}

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

button.secondary {
  background: #eceae5;
  color: var(--ink);
}

.guess-group {
  margin-top: 16px;
}

.guess-header {
  margin-bottom: 8px;
  font-size: 0.9rem;
  color: var(--muted);
}

.guess-slot {
  position: relative;
  width: 56px;
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fafaf6;
  overflow: visible;
}
 
.guess-slot.black {
  background: var(--black);
}
 
.guess-slot.white {
  background: var(--white);
}
 
.guess-slot.yellow {
  background: var(--yellow);
}
 
.guess-slot-button {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 76px;
  border: none;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}
 
.guess-value {
  position: relative;
  z-index: 1;
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1;
  pointer-events: none;
}
 
.guess-picker {
  position: fixed;
  z-index: 40;
  left: 50%;
  top: 12px;
  transform: none;
  width: min(280px, calc(100vw - 18px));
  display: none;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.12);
  padding: 8px;
}

.guess-picker.open {
  display: grid;
}
 
.guess-picker-option {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 10px;
  min-height: 42px;
  font-weight: 800;
  font-size: 1rem;
  cursor: pointer;
  background: var(--panel-alt);
  color: var(--ink);
}
 
.guess-picker-option.black {
  background: var(--black);
  color: white;
}
 
.guess-picker-option.white {
  background: var(--white);
  color: var(--ink);
}
 
.guess-picker-option.yellow {
  background: var(--yellow);
  color: #4d3d00;
}
 
.guess-picker-option.clear {
  background: #f3f3f1;
  color: var(--ink);
}

.hidden-board {
  min-height: 88px;
  align-items: center;
}

.elimination-list {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.elimination-card {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 6px 4px;
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--ink);
  position: relative;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.25);
}

.elimination-card.black {
  background: var(--black);
  color: white;
}

.elimination-card.white {
  background: var(--white);
  color: var(--ink);
}

.elimination-card.yellow {
  background: var(--yellow);
  color: #5c4e00;
}

.elimination-card.eliminated {
  color: var(--danger);
  border-color: rgba(201, 64, 64, 0.5);
  background: #fff3f3;
}

.elimination-card.eliminated::after {
  content: "×";
  position: absolute;
  font-size: 1.4rem;
  color: var(--danger);
  font-weight: 800;
}

.note {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.8rem;
}

@media (max-width: 420px) {
  body {
    padding-inline: 10px;
  }

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

  .opponent-grid,
  .opponent-guess-grid {
    grid-template-columns: 1fr;
  }

  .elimination-list {
    grid-template-columns: repeat(10, minmax(0, 1fr));
  }
}
