:root {
  --ink: #202036;
  --panel: rgba(255, 255, 255, 0.9);
  --red: #ff6363;
  --yellow: #ffbe42;
  --green: #47d978;
  --blue: #459fff;
  --purple: #a96dff;
  --pink: #ff78bd;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: linear-gradient(135deg, #2896f2, #19c79e);
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  border-radius: 18px;
  padding: 14px 18px;
  color: white;
  background: var(--purple);
  font-weight: 900;
  box-shadow: 0 7px 0 rgba(0, 0, 0, 0.16);
  cursor: pointer;
}

button:active {
  transform: translateY(3px);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.16);
}

input {
  width: 100%;
  border: 0;
  border-radius: 16px;
  padding: 15px 16px;
  color: var(--ink);
  background: white;
  font-weight: 800;
  outline: none;
}

.app {
  width: min(100vw, 520px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  color: white;
}

h1 {
  margin: 0;
  font-size: clamp(2.1rem, 10vw, 3.4rem);
  line-height: 0.94;
  letter-spacing: 0;
  text-shadow: 0 5px 0 rgba(0, 0, 0, 0.16);
}

p {
  margin: 8px 0 0;
  font-weight: 800;
}

.panel {
  margin-top: 24px;
  padding: 18px;
  border-radius: 28px;
  background: var(--panel);
}

.auth {
  display: grid;
  gap: 12px;
}

.buttonRow {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.secondary {
  background: var(--pink);
}

.ghost {
  width: auto;
  padding: 10px 12px;
  color: var(--ink);
  background: #ffdf51;
}

.wide {
  width: 100%;
}

.profileRow,
.scorebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.label,
.scorebar span,
.boardGroup span {
  display: block;
  color: rgba(32, 32, 54, 0.62);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.profileRow strong {
  display: block;
  margin-top: 4px;
  font-size: 1.8rem;
}

.trophy {
  border-radius: 999px;
  padding: 10px 14px;
  background: #ffdf51;
  font-weight: 1000;
}

.play {
  width: 100%;
  margin-top: 18px;
  font-size: 1.2rem;
}

.debug {
  overflow-wrap: anywhere;
  color: rgba(32, 32, 54, 0.66);
  font-size: 0.78rem;
  line-height: 1.35;
}

.game {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.scorebar {
  color: white;
}

.scorebar > div {
  min-width: 86px;
  border-radius: 16px;
  padding: 9px 10px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.9);
  text-align: center;
}

.scorebar strong {
  display: block;
  font-size: 1.2rem;
}

.scorebar .timer {
  min-width: 76px;
  color: white;
  background: rgba(0, 0, 0, 0.22);
  font-size: 1.5rem;
  font-weight: 1000;
}

.boardGroup {
  display: grid;
  gap: 5px;
}

.boardGroup span {
  color: white;
  padding-left: 8px;
}

.board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
  aspect-ratio: 2 / 1;
  padding: 10px;
  border-radius: 24px;
  background: rgba(0, 0, 0, 0.16);
  touch-action: none;
}

.board.opponent {
  gap: 4px;
  padding: 8px;
  border-radius: 18px;
  background: rgba(0, 0, 0, 0.11);
}

.cell {
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.28);
  outline: 1px solid rgba(255, 255, 255, 0.35);
}

.opponent .cell {
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.16);
}

.tray {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 24px;
  min-height: 120px;
  touch-action: none;
}

.piece {
  position: relative;
  width: 92px;
  height: 92px;
  cursor: grab;
  touch-action: none;
  filter: drop-shadow(0 7px 0 rgba(0, 0, 0, 0.16));
}

.piece.dragging {
  position: fixed;
  z-index: 10;
  transform: translate(-50%, -50%) scale(1.12);
}

.block {
  position: absolute;
  border-radius: 8px;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.3);
}

.result {
  display: grid;
  gap: 16px;
}

.resultHero {
  border-radius: 22px;
  padding: 18px;
  color: white;
  background: var(--purple);
  box-shadow: 0 7px 0 rgba(0, 0, 0, 0.16);
  font-size: clamp(2rem, 8vw, 3.4rem);
  font-weight: 1000;
  line-height: 0.95;
  text-align: center;
}

.resultHero.loss {
  background: var(--pink);
}

.resultHero.draw {
  background: var(--blue);
}

.resultGrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.resultStat {
  border-radius: 20px;
  padding: 14px;
  background: white;
}

.resultStat span,
.resultStat em {
  display: block;
  color: rgba(32, 32, 54, 0.62);
  font-size: 0.78rem;
  font-style: normal;
  font-weight: 900;
  text-transform: uppercase;
}

.resultStat strong {
  display: block;
  margin: 7px 0;
  color: var(--ink);
  font-size: 2rem;
  font-weight: 1000;
}

.resultStat.you {
  outline: 4px solid rgba(71, 217, 120, 0.24);
}

.resultStat.rival {
  outline: 4px solid rgba(255, 120, 189, 0.2);
}

.hidden {
  display: none !important;
}
