/* YKSI page – the game box is in css/game-stage.css, the look shared with the other robot games (big text,
   bubbles, menus, back button) in css/holo-games.css. The table and the cards are drawn on the canvas. */

/* Phones held upright: a taller box, so the hand and the table both fit */
@media (max-aspect-ratio: 1/1) {
  .uno-stage {
    --aspect: 3 / 4;
  }
}

/* ---------- Fullscreen on a big screen, a low window ---------- */
/* The HTML parts follow the game box like the cards do (owner, Oct 2026): --ui is 1 at 960 x 540 (js/game-ui.js
   stageScale; less in a box shrunk to fit a low window). zoom only on things in the flow – the boxes placed by uno.js
   keep their px places. A menu taller than the box shrinks a little more (--menu-fit, js/game-ui.js keepMenusInBox). */
.uno-seat > *,
.uno-actions > *,
.uno-picker > * {
  zoom: var(--ui, 1);
}

.uno-stage .overlay > * {
  zoom: calc(var(--ui, 1) * var(--menu-fit, 1));
}

/* ---------- The robots' name tags (placed by uno.js) ---------- */

.uno-seat {
  position: absolute;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  max-width: calc(15rem * var(--ui, 1));
  padding: calc(0.25rem * var(--ui, 1)) calc(0.7rem * var(--ui, 1));
  font-style: italic;
  font-weight: 800;
  text-transform: uppercase;
  line-height: 1.1;
  text-align: center;
  color: var(--text-muted);
  background: rgba(14, 10, 36, 0.72);
  border: 2px solid rgba(94, 240, 255, 0.25);
  clip-path: polygon(0.5rem 0, 100% 0, calc(100% - 0.5rem) 100%, 0 100%);   /* the site's angled shapes */
  transform: translateX(-50%);
  transition: color 0.2s, border-color 0.2s, box-shadow 0.2s;
  pointer-events: none;
}

.uno-seat.is-left-aligned {
  transform: none;
}

.uno-seat-name {
  font-size: clamp(0.72rem, 1.6vw, 0.95rem);
  overflow-wrap: break-word;
}

.uno-seat-count {
  font-size: clamp(0.8rem, 1.8vw, 1.05rem);
  color: var(--yellow);
}

/* Who a Hoppa över / +2 / +4 hit: lit in the card's colour (--hit, set by uno.js) for a moment */
.uno-seat.is-hit {
  color: var(--text);
  border-color: var(--hit, #ff3b3b);
  box-shadow: 0 0 18px var(--hit, #ff3b3b), inset 0 0 12px var(--hit, #ff3b3b);
}

/* Whose turn it is: the same yellow light as round the robot and the beam on the table */
.uno-seat.is-turn {
  color: var(--text);
  border-color: var(--yellow);
  animation: uno-turn 1.6s ease-in-out infinite alternate;
}

@keyframes uno-turn {
  from { box-shadow: 0 0 6px rgba(255, 233, 77, 0.45), inset 0 0 8px rgba(255, 233, 77, 0.25); }
  to { box-shadow: 0 0 18px rgba(255, 233, 77, 0.85), inset 0 0 14px rgba(255, 233, 77, 0.4); }
}

@media (prefers-reduced-motion: reduce) {
  .uno-seat.is-turn {
    animation: none;
    box-shadow: 0 0 14px rgba(255, 233, 77, 0.7);
  }
}

/* One card left: the count pulses */
.uno-seat.is-one .uno-seat-count {
  color: var(--magenta);
  animation: uno-pulse 0.7s ease-in-out infinite alternate;
}

/* Skipped: the tag flashes red for a moment */
.uno-seat.is-skipped {
  animation: uno-skipped 0.9s ease-out;
}

@keyframes uno-skipped {
  0%, 40% { border-color: #ff3b3b; box-shadow: 0 0 18px rgba(255, 59, 59, 0.8); }
  100% { border-color: rgba(94, 240, 255, 0.25); box-shadow: none; }
}

@keyframes uno-pulse {
  from { text-shadow: 0 0 0 transparent; }
  to { text-shadow: 0 0 10px rgba(255, 63, 180, 0.9); }
}

/* A robot forgot "YKSI!": catch it */
.uno-catch {
  margin-top: 0.2rem;
  padding: 0.25rem 0.8rem;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 900;
  color: #fff;
  background: var(--magenta);
  border: none;
  clip-path: polygon(0.4rem 0, 100% 0, calc(100% - 0.4rem) 100%, 0 100%);
  cursor: pointer;
  pointer-events: auto;
  animation: uno-catch 0.5s ease-in-out infinite alternate;
}

.uno-catch[hidden] {
  display: none;
}

@keyframes uno-catch {
  from { transform: scale(1); box-shadow: 0 0 0 transparent; }
  to { transform: scale(1.08); box-shadow: 0 0 14px var(--magenta); }
}

/* A long big text ("Ny färg: Grön!", "Du glömde YKSI! +2") is smaller, so it doesn't cover the whole table */
#big-text {
  font-size: calc(clamp(2rem, 9vw, 5.5rem) * var(--ui, 1));
}

#big-text.is-long {
  font-size: calc(clamp(1.6rem, 5.5vw, 3.4rem) * var(--ui, 1));
}

/* "Pipens tur" / "Din tur!" when the turn passes on (yellow like the turn light, set by uno.js) */
#big-text.is-call {
  font-size: calc(clamp(1.5rem, 5vw, 3.1rem) * var(--ui, 1));
}

/* ---------- Speech bubbles (placed next to each robot's head by uno.js; data-side = where the robot is) ---------- */

.uno-bubble {
  max-width: min(calc(17rem * var(--ui, 1)), 34%);
  padding: calc(0.45rem * var(--ui, 1)) calc(0.8rem * var(--ui, 1));
  font-size: calc(clamp(0.85rem, 1.9vw, 1.15rem) * var(--ui, 1));
  transform-origin: top left;
}

.uno-bubble[data-side="left"]::before {          /* the robot is to the left: the tail points left */
  top: calc(0.8rem * var(--ui, 1));
  left: calc(-0.55rem * var(--ui, 1));
  border: calc(0.5rem * var(--ui, 1)) solid transparent;
  border-left: 0;
  border-right-color: var(--yellow);
}

.uno-bubble[data-side="right"] {                 /* the robot is to the right: the bubble grows leftwards */
  transform: translateX(-100%) translateY(-0.4rem) scale(0.9);
  transform-origin: top right;
}

.uno-bubble[data-side="right"].show {
  transform: translateX(-100%);
}

.uno-bubble[data-side="right"]::before {
  top: calc(0.8rem * var(--ui, 1));
  right: calc(-0.55rem * var(--ui, 1));
  border: calc(0.5rem * var(--ui, 1)) solid transparent;
  border-right: 0;
  border-left-color: var(--yellow);
}

.uno-bubble[data-side="top"] {                   /* a tall box: under the name tags, in the middle */
  max-width: 88%;
  transform: translateX(-50%) translateY(-0.4rem) scale(0.9);
  transform-origin: top center;
}

.uno-bubble[data-side="top"].show {
  transform: translateX(-50%);
}

.uno-bubble[data-side="top"]::before {
  left: calc(50% - 0.5rem * var(--ui, 1));
}

/* ---------- Above your cards: the action buttons and a hint (placed by uno.js) ---------- */
/* Owner, Oct 2026: "Behåll", "YKSI!" and "Avsluta tur" where the help text was – the game SHOWS what to do
   (the draw pile lights up, the cards that fit lift) instead of telling it. */

.uno-actions {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  margin-bottom: 0.3rem;
  pointer-events: none;
}

.uno-action-row {
  display: flex;
  justify-content: center;
  gap: 0.7rem;
}

/* A hint after a card that doesn't fit (empty = takes no room) */
.uno-status {
  margin: 0;
  padding: 0 4rem;
  font-style: italic;
  font-weight: 800;
  text-transform: uppercase;
  font-size: clamp(0.8rem, 2vw, 1.15rem);
  color: var(--yellow);
  text-align: center;
  text-shadow: 0 0 8px rgba(255, 233, 77, 0.6), 0 1px 3px #000;
}

.uno-status:empty {
  display: none;
}

/* The site's second button (button-secondary, magenta since 2026-10-13), on a dark backing so it reads over the table */
.uno-pass {
  padding: 0.45rem 1.2rem;
  font-size: 1rem;
  background: linear-gradient(rgba(255, 63, 180, 0.2), rgba(255, 63, 180, 0.2)), rgba(10, 7, 32, 0.88);
  pointer-events: auto;
}

/* "Avsluta tur" (owner, 2026-10-13: "it needs attention"): a cyan outline. The button's shape is a clip-path, which a
   border can't follow, so the outline is drawn as background layers like .button's inner glow (style.css): a 2 px line
   at the top and bottom, and one on each angled side (a 48 px box centred on the side, its diagonal on the side). */
.uno-pass.is-end {
  --edge-line: var(--cyan) 0, var(--cyan) 2px, transparent 2px;
  --side-line: transparent 50%, var(--cyan) 50%, var(--cyan) calc(50% + 2px), transparent calc(50% + 2px);
  background:
    linear-gradient(to bottom, var(--edge-line)) 0 0 / 100% 100% no-repeat,
    linear-gradient(to top, var(--edge-line)) 0 0 / 100% 100% no-repeat,
    linear-gradient(to bottom right, var(--side-line)) -18px 50% / 48px 400% no-repeat,
    linear-gradient(to top left, var(--side-line)) right -18px top 50% / 48px 400% no-repeat,
    linear-gradient(rgba(255, 63, 180, 0.2), rgba(255, 63, 180, 0.2)),
    rgba(10, 7, 32, 0.88);
}

.uno-pass[hidden] {
  display: none;
}

/* YKSI!: only shown when you may say it (two cards on your turn) – pulsing; shaking when you forgot it */
.uno-call {
  min-width: 5.2rem;
  padding: 0.35rem 1rem;
  font: inherit;
  font-style: italic;
  font-weight: 900;
  font-size: clamp(1.1rem, 2.6vw, 1.6rem);
  letter-spacing: 0.04em;
  color: #fff;
  background: var(--magenta);
  border: 2px solid var(--magenta);
  clip-path: polygon(0.6rem 0, 100% 0, calc(100% - 0.6rem) 100%, 0 100%);
  cursor: pointer;
  pointer-events: auto;
  animation: uno-ready 0.9s ease-in-out infinite alternate;
}

.uno-call[hidden] {
  display: none;
}

/* You forgot it! Quick, before someone catches you */
.uno-call.is-urgent {
  animation: uno-urgent 0.3s ease-in-out infinite alternate;
}

@keyframes uno-ready {
  from { box-shadow: 0 0 4px var(--magenta); filter: brightness(1); }
  to { box-shadow: 0 0 18px var(--magenta); filter: brightness(1.2); }
}

@keyframes uno-urgent {
  from { transform: scale(1); filter: brightness(1); }
  to { transform: scale(1.12); filter: brightness(1.4); }
}

/* ---------- The colour picker ---------- */

.uno-picker {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  padding: 0.9rem 1.1rem;
  background: rgba(10, 7, 32, 0.92);
  border: 2px solid var(--cyan);
  box-shadow: 0 0 22px rgba(94, 240, 255, 0.45);
  transform: translate(-50%, -50%);
}

.uno-picker[hidden] {
  display: none;
}

.uno-picker-title {
  margin: 0;
  font-style: italic;
  font-weight: 900;
  font-size: 1.3rem;
  text-transform: uppercase;
  color: var(--yellow);
}

.uno-picker-colours {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
}

.uno-colour {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  width: clamp(3.6rem, 11vw, 5.2rem);
  padding: 0.5rem 0.3rem 0.4rem;
  font: inherit;
  font-weight: 900;
  font-style: italic;
  text-transform: uppercase;
  color: #fff;
  text-shadow: 0 1px 2px #1a0f3a, 0 0 4px #1a0f3a;
  background: var(--colour);
  border: 3px solid rgba(255, 255, 255, 0.6);
  border-radius: 0.6rem;
  box-shadow: 0 0 12px var(--colour);
  cursor: pointer;
}

.uno-colour canvas {
  width: 2rem;
  height: 2rem;
}

.uno-colour:hover,
.uno-colour:focus-visible {
  border-color: #fff;
  outline: none;
  transform: scale(1.08);
  box-shadow: 0 0 22px var(--colour);
}

/* Phones held upright: two rows of two */
@media (max-width: 420px) {
  .uno-picker-colours {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ---------- Menus ---------- */

/* Wide boxes: how many robots + the buttons on the left, who sits where on the right (so it all fits) */
@media (min-aspect-ratio: 1/1) and (min-width: 640px) {
  #menu {
    display: grid;
    grid-template-columns: auto auto;
    align-items: center;
    column-gap: 2.2rem;
    row-gap: 0.6rem;
  }
  #count-row {
    grid-column: 1;
    grid-row: 1;
  }
  #stack-row {
    grid-column: 1;
    grid-row: 2;
  }
  #multi-row {
    grid-column: 1;
    grid-row: 3;
  }
  #seat-picks {
    grid-column: 2;
    grid-row: 1 / span 3;
  }
  #menu > .uno-menu-buttons {                       /* Spela! + Hur spelar man? side by side under both columns */
    grid-column: 1 / span 2;
    grid-row: 4;
    justify-content: center;
    margin-top: 0.4rem;
  }
}

.uno-seat-picks {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.uno-robot-choice {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 5.2rem;
  line-height: 1.1;
}

.uno-robot-choice small {
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  opacity: 0.8;
}

.uno-menu-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.6rem;
}

.uno-menu-buttons[hidden] {
  display: none;
}

/* "Hur spelar man?" */
.uno-rules {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
  max-width: 38rem;
}

.uno-rules[hidden] {
  display: none;
}

.uno-rules-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin: 0;
  padding: 0;
  list-style: none;
  text-align: left;
}

.uno-rules-list li {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  font-size: 0.95rem;
  line-height: 1.3;
}

/* Wide boxes: the cards in two columns, so it all fits without scrolling */
@media (min-aspect-ratio: 1/1) and (min-width: 640px) {
  .uno-rules-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 1.4rem;
  }
  .uno-rules-list li.is-text {
    grid-column: 1 / -1;
  }
  /* A little tighter, so "Jag fattar!" fits in the box without scrolling */
  .uno-rules {
    gap: 0.5rem;
  }
  .uno-rules-list {
    gap: 0.3rem;
  }
  .uno-rules-list li {
    font-size: 0.88rem;
    line-height: 1.25;
  }
  .uno-rules-list img {
    width: 2.1rem;
  }
}

.uno-rules-list img {
  flex: none;
  width: 2.4rem;
  height: auto;
}

@media (max-width: 560px) {
  .uno-rules-list li {
    font-size: 0.85rem;
  }
  .uno-robot-choice {
    min-width: 4.4rem;
  }
}

/* On the net: a player whose connection is lost is dim (js/net-menus.js says so at the top too) */
.uno-seat.is-gone {
  opacity: 0.45;
}
