* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Arial, sans-serif;
  background: #111827;
  color: #fff;
}
.app {
  max-width: 560px;
  margin: 0 auto;
  padding: 20px 20px 36px;
}
h1 {
  margin-bottom: 8px;
  font-size: 32px;
}
.subtitle {
  color: #cbd5e1;
  margin-top: 0;
}
.panel {
  background: #1f2937;
  border-radius: 16px;
  padding: 16px;
  margin: 16px 0;
}
.hidden { display: none !important; }
label { display: block; margin-bottom: 12px; }
input {
  width: 100%;
  margin-top: 6px;
  padding: 12px;
  border-radius: 10px;
  border: none;
  font-size: 16px;
}
button {
  border: none;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 16px;
  cursor: pointer;
}
button:disabled {
  opacity: 0.6;
  cursor: default;
}
.secondary {
  background: #334155;
  color: #fff;
}
.reward {
  background: #a855f7;
  color: #fff;
}
.actions, .joinBox {
  display: flex;
  gap: 10px;
}
.actions {
  margin-bottom: 10px;
}
.actions button,
.joinBox button,
.joinBox input {
  flex: 1;
  min-width: 0;
}
.topRow {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.topButtons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: flex-start;
  flex: 1 1 260px;
}
.topButtons .small {
  flex: 1 1 auto;
  min-width: 0;
}
.small { padding: 10px 12px; font-size: 14px; }
.roomCodeWrap {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
  flex-wrap: wrap;
}
.label {
  color: #94a3b8;
  font-size: 14px;
}
.scoreRow {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 16px 0;
}
.scoreCard,
.status,
.playerCard {
  background: #0f172a;
  border-radius: 10px;
  padding: 12px;
}
.scoreCard {
  text-align: center;
  font-size: 14px;
}
.status {
  margin: 16px 0;
}
.players {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}
.board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.cell {
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  background: #334155;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(42px, 8vw, 52px);
  font-weight: bold;
  user-select: none;
}
.cell.disabled { opacity: 0.7; }
.cell.hint {
  outline: 3px solid #facc15;
  outline-offset: -3px;
}
.message {
  min-height: 24px;
  color: #fca5a5;
}
.loaderOverlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(2, 6, 23, 0.94);
}
.loaderCard {
  width: min(360px, 100%);
  padding: 24px;
  border-radius: 18px;
  background: #1f2937;
  text-align: center;
}
.loaderSpinner {
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  border-radius: 50%;
  border: 5px solid #334155;
  border-top-color: #fff;
  animation: spin 1s linear infinite;
}
.loaderTitle {
  font-size: 22px;
  font-weight: bold;
  margin-bottom: 8px;
}
.loaderText {
  color: #cbd5e1;
  font-size: 14px;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 560px) {
  .stackOnMobile,
  .stackTopRow,
  .topButtons {
    flex-direction: column;
  }

  .stackOnMobile > *,
  .topButtons > * {
    width: 100%;
  }

  .players,
  .scoreRow {
    grid-template-columns: 1fr;
  }
}
