/* Pig Game - modernised version of the original Lato/teal design */

:root {
  --accent: #0097a7;
  --accent-dark: #00727e;
  --text: #4a4a4a;
  --muted: #8a8a8a;
  --panel: #ffffff;
  --panel-active: #eaf5f6;
  --radius: 20px;
  --font: "Lato", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html { font-size: 16px; }

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  padding: 2rem 1rem;
  font-family: var(--font);
  font-weight: 300;
  color: var(--text);
  background:
    radial-gradient(circle at 20% 15%, rgba(0, 151, 167, 0.45), transparent 55%),
    radial-gradient(circle at 85% 85%, rgba(239, 79, 82, 0.35), transparent 50%),
    linear-gradient(135deg, #1d2b3a 0%, #3e1414 100%);
}

/* ---------- Layout ---------- */

.game {
  position: relative;
  width: min(1000px, 100%);
  display: grid;
  grid-template-columns: 1fr minmax(200px, 240px) 1fr;
  grid-template-areas: "p0 controls p1";
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

.player--0 { grid-area: p0; }
.player--1 { grid-area: p1; }
.controls { grid-area: controls; }

/* ---------- Players ---------- */

.player {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  padding: 4rem 2rem;
  min-height: 560px;
  transition: background-color 0.3s;
}

.player--active { background-color: var(--panel-active); }

.player__name {
  position: relative;
  font-size: 2.25rem;
  font-weight: 300;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text);
}

.player--active .player__name { font-weight: 600; }

.player--active .player__name::after {
  content: "";
  position: absolute;
  top: 50%;
  right: -1.25rem;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  transform: translateY(-50%);
}

.player__score {
  font-size: 5rem;
  font-weight: 300;
  line-height: 1;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.player__current {
  margin-top: auto;
  width: min(180px, 80%);
  padding: 1rem;
  border-radius: 14px;
  background: var(--accent);
  color: #fff;
  text-align: center;
}

.player__current-label {
  font-size: 0.75rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.8);
  margin-bottom: 0.4rem;
}

.player__current-score {
  font-size: 2rem;
  font-variant-numeric: tabular-nums;
}

.player--winner { background-color: #dff2f4; }
.player--winner .player__name { color: var(--accent); font-weight: 600; }

/* ---------- Controls ---------- */

.controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 2.5rem 1rem;
  border-left: 1px solid #eee;
  border-right: 1px solid #eee;
}

.dice-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  min-height: 210px;
}

.dice {
  width: 96px;
  height: 96px;
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
}

.dice--rolling { animation: roll 0.35s ease-out; }

@keyframes roll {
  0%   { transform: rotate(-30deg) scale(0.7); opacity: 0.4; }
  70%  { transform: rotate(8deg) scale(1.05); opacity: 1; }
  100% { transform: rotate(0) scale(1); }
}

.hidden { visibility: hidden; }

.actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1.1rem;
  border: none;
  border-radius: 999px;
  background: none;
  color: var(--text);
  font-family: inherit;
  font-size: 1.1rem;
  font-weight: 300;
  text-transform: uppercase;
  letter-spacing: 1px;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s, font-weight 0.2s;
}

.btn svg {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.25s;
}

.btn:hover:not(:disabled) { background: #eef7f8; font-weight: 600; }
.btn:hover:not(:disabled) svg { transform: translateX(-3px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: 0.35; cursor: not-allowed; }

.final-score-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  margin-top: 1rem;
  font-size: 0.7rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
}

.final-score {
  width: 140px;
  padding: 0.6rem;
  border: 1px solid #ddd;
  border-radius: 10px;
  font-family: inherit;
  font-size: 1.1rem;
  text-align: center;
  color: var(--text);
}

.final-score:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0, 151, 167, 0.2); }
.final-score:disabled { background: #f6f6f6; color: var(--muted); }

/* ---------- Extras ---------- */

.rules {
  width: min(1000px, 100%);
  padding: 1rem 1.5rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.92);
  font-size: 0.95rem;
}

.rules summary { cursor: pointer; font-weight: 600; color: var(--accent-dark); }
.rules ul { margin: 0.75rem 0 0 1.25rem; line-height: 1.6; }

.credit { font-size: 0.85rem; color: rgba(255, 255, 255, 0.75); text-align: center; }
.credit a { color: #fff; }

/* ---------- Responsive ---------- */

@media (max-width: 760px) {
  .game {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "p0 p1"
      "controls controls";
  }

  .player { min-height: 0; padding: 2rem 1rem; gap: 1rem; }
  .player__name { font-size: 1.4rem; }
  .player__score { font-size: 3.5rem; }
  .player__current { margin-top: 0; }

  .controls { border: none; border-top: 1px solid #eee; padding: 1.5rem 1rem; }
  .dice-area { flex-direction: row; min-height: 96px; }
  .dice { width: 80px; height: 80px; }
  .actions { flex-direction: row; flex-wrap: wrap; justify-content: center; }
  .final-score-label { width: 100%; margin-top: 0.5rem; }
}
