* {
  box-sizing: border-box;
}

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

body {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", sans-serif;
  background: #f5f6f8;
  color: #222;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

#app {
  width: min(100%, 640px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 20px 16px;
}

.screen {
  height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
}

.screen[hidden] {
  display: none;
}

.screen.center {
  justify-content: center;
}

.container {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.card {
  background: #fff;
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}

.card + .card {
  margin-top: 16px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  text-align: center;
}

h2 {
  margin-bottom: 16px;
}

h3 {
  margin-bottom: 12px;
}

.subtitle {
  margin-bottom: 28px;
  text-align: center;
  color: #666;
}

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
}

.field input {
  width: 100%;
  height: 46px;
  padding: 0 12px;
  border: 1px solid #ccc;
  border-radius: 8px;
  background: #fff;
}

.button {
  width: 100%;
  min-height: 48px;
  margin-top: 10px;
  border: 0;
  border-radius: 10px;
  background: #222;
  color: #fff;
  font-weight: 700;
}

.button.secondary {
  background: #e9eaed;
  color: #222;
}

.button:active {
  transform: translateY(1px);
}

.button:disabled {
  opacity: 0.2;
  cursor: default;
}

.room-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding: 4px 2px;
}

.room-id {
  margin-top: 4px;
  color: #666;
  font-size: 14px;
}

.badge {
  padding: 5px 9px;
  border-radius: 999px;
  background: #e9eaed;
  font-size: 12px;
  font-weight: 700;
}

.players {
  list-style: none;
  margin: 0;
  padding: 0;
}

.players li {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid #eee;
}

.players li:last-child {
  border-bottom: 0;
}

.notice {
  margin-bottom: 12px;
  padding: 14px;
  border-radius: 10px;
  background: #fff;
  color: #666;
  text-align: center;
  font-size: 14px;
}

.spacer {
  flex: 1;
  min-height: 24px;
}

.question-number {
  font-weight: 700;
}

.timer {
  margin: 0 0 16px;
  text-align: center;
  font-size: 28px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.question {
  margin-bottom: 20px;
  font-size: 22px;
  line-height: 1.5;
  font-weight: 700;
}

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

.choice {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 58px;
  padding: 10px 14px;
  border: 1px solid #d5d6da;
  border-radius: 10px;
  background: #fff;
  color: #222;
  text-align: left;
}

.choice:hover:not(:disabled) {
  background: #f5f6f8;
}

.choice.selected {
  border-color: #222;
  background: #eee;
}

.choice:disabled {
  cursor: default;
}

.choice-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #eee;
  font-weight: 700;
}

.rank {
  margin-bottom: 8px;
  font-weight: 700;
}

.score {
  margin-bottom: 20px;
  font-size: 42px;
  font-weight: 800;
}

.result-table {
  width: 100%;
  border-collapse: collapse;
}

.result-table th,
.result-table td {
  padding: 10px 6px;
  border-bottom: 1px solid #eee;
  text-align: left;
}

.result-table th:last-child,
.result-table td:last-child {
  text-align: right;
}

.choice-select {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.choice-select button {
  min-height: 48px;
  border: 1px solid #ccc;
  border-radius: 8px;
  background: #fff;
  font-weight: 700;
}

.choice-select button.active {
  border-color: #222;
  background: #222;
  color: #fff;
}

.host-controls {
  display: grid;
  gap: 2px;
}

@media (max-width: 480px) {
  #app {
    padding: 12px;
  }

  .screen {
    min-height: calc(100vh - 24px);
  }

  .card {
    padding: 16px;
  }

  .question {
    font-size: 20px;
  }

  .score {
    font-size: 36px;
  }
}
