/* Farben, Schriften und Radius kommen aus /mediathek/spiele/gemeinsam/spiele.css.
   Hier stehen nur die Brettfarben und die Regeln dieses Spiels. */
:root {
  --light-sq: #FFFFFF;
  --dark-sq: #9AA3A8;
  --marker: rgba(0, 203, 255, 0.38);   /* Leuchtstift: letzter Zug */
  --marker-stark: rgba(0, 203, 255, 0.55);
}

* { box-sizing: border-box; }

body {
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 1080px;
  margin: 0 auto;
  padding: 32px clamp(12px, 4vw, 48px) 40px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ---------- Spieltitel ---------- */

.app__bar {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 20px;
  border-bottom: 2px solid var(--tinte);
  padding-bottom: 14px;
}

.app__title {
  margin: 0;
  font-family: var(--schrift-titel);
  font-size: clamp(1.9rem, 3.6vw, 2.6rem);
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: -0.025em;
  color: var(--tinte);
}

.app__subtitle {
  margin: 0;
  font-size: 0.95rem;
  color: var(--text-leise);
}

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

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 32px;
  align-items: start;
}

.table {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  width: 100%;
  max-width: min(100%, max(420px, calc(100vh - 230px)));
}

.side {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

/* ---------- Spielerzeilen ---------- */

.player {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 28px;
  padding: 0 2px;
  font-size: 14px;
}

.player__dot {
  width: 10px;
  height: 10px;
  background: var(--linie);
  flex: none;
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

.player.is-active .player__dot {
  background: var(--tinte);
  box-shadow: 0 0 0 3px var(--cyan);
}

.player__name {
  font-weight: 500;
  color: var(--text-leise);
  white-space: nowrap;
}

.player.is-active .player__name { color: var(--tinte); font-weight: 600; }

/* ---------- Brett ---------- */

.board {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.board__frame {
  position: relative;
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) 16px;
  gap: 0;
  background: var(--papier);
}

.coords {
  display: flex;
  font-family: var(--schrift-text);
  font-size: 10px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--text-leise);
  user-select: none;
}

.coords--ranks {
  grid-area: 1 / 1;
  flex-direction: column;
  justify-content: space-around;
  align-items: center;
}

.coords--files {
  grid-area: 2 / 2;
  flex-direction: row;
  justify-content: space-around;
  align-items: center;
}

.grid {
  grid-area: 1 / 2;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  aspect-ratio: 1 / 1;
  position: relative;
  outline: 1px solid var(--tinte);
  touch-action: manipulation;
}

.grid:focus-visible {
  outline: 2px solid var(--tinte);
  outline-offset: 2px;
  box-shadow: 0 0 0 5px var(--cyan);
}

.sq {
  position: relative;
  width: 12.5%;
  height: 12.5%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: var(--light-sq);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.sq--dark { background: var(--dark-sq); }

.sq__piece {
  position: relative;
  z-index: 2;
  display: block;
  pointer-events: none;
}

/* ---------- Markierungen: Cyan als Leuchtstift ---------- */

.sq.is-last { background-image: linear-gradient(var(--marker), var(--marker)); }

.sq.is-selected::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--marker-stark);
  box-shadow: inset 0 0 0 3px var(--tinte);
}

/* Zielfeld: Cyan-Punkt mit Tintenrand, auf hellen wie dunklen Feldern sichtbar. */
.sq.is-target::before {
  content: "";
  position: absolute;
  z-index: 3;
  width: 26%;
  height: 26%;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 0 2px var(--tinte);
}

/* Schlagzielfeld: Ring statt Punkt. */
.sq.is-target.is-capture::before {
  width: 88%;
  height: 88%;
  background: transparent;
  border: 4px solid var(--cyan);
  box-shadow: 0 0 0 2px var(--tinte), inset 0 0 0 2px var(--tinte);
}

.sq.is-cursor { box-shadow: inset 0 0 0 3px var(--tinte), inset 0 0 0 6px var(--cyan); }

.sq:focus { outline: none; }

/* ---------- Panels ---------- */

.panel {
  background: var(--papier);
  border: 1px solid var(--linie);
  border-top: 2px solid var(--tinte);
  padding: 14px 16px 16px;
}

.panel--status { padding: 14px 16px; }

.status {
  margin: 0;
  font-size: 15px;
  font-weight: 500;
  color: var(--tinte);
}

.status.is-thinking::after {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-left: 8px;
  background: var(--tinte);
  animation: pulse 0.9s ease-in-out infinite;
  vertical-align: middle;
}

.status.is-over { font-weight: 700; }

@keyframes pulse {
  0%, 100% { opacity: 0.25; }
  50% { opacity: 1; }
}

.panel__title {
  margin: 0 0 10px;
  font-family: var(--schrift-text);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--tinte);
}

.panel__empty {
  margin: 0;
  color: var(--text-leise);
  font-size: 13px;
}

/* ---------- Zugliste ---------- */

.moves {
  margin: 0;
  padding: 0;
  list-style: none;
  max-height: 236px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.moves__row {
  display: grid;
  align-items: center;
  gap: 4px;
  border-bottom: 1px solid var(--linie);
}

.moves__no {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--text-leise);
}

.moves__san {
  padding: 5px 8px;
  font: inherit;
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
  text-align: left;
  color: var(--tinte);
  background: transparent;
  border: 0;
  border-radius: 0;
}

.moves__san.is-current {
  font-weight: 700;
  box-shadow: inset 0 -3px 0 var(--cyan);
}

/* ---------- Bedienung ---------- */

.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

.controls .button:first-child { grid-column: 1 / -1; }

.button {
  min-height: 44px;
  padding: 9px 12px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--papier);
  background: var(--tinte);
  border: 2px solid var(--tinte);
  border-radius: 0;
  cursor: pointer;
  transition: background-color 180ms var(--ease), color 180ms var(--ease);
}

.button:hover { background: var(--papier); color: var(--tinte); }
.button:disabled { opacity: 0.4; cursor: default; }
.button:disabled:hover { background: var(--tinte); color: var(--papier); }

.field { margin-top: 12px; }

.field__label {
  display: block;
  margin-bottom: 5px;
  font-size: 13px;
  color: var(--text-leise);
}

.field__input {
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  font: inherit;
  font-size: 14px;
  color: var(--tinte);
  background: var(--papier);
  border: 1px solid var(--tinte);
  border-radius: 0;
}

/* ---------- Tastenlegende ---------- */

.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 20px;
  padding-top: 14px;
  border-top: 1px solid var(--linie);
}

.legend__group {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-leise);
}

.legend__copyright {
  flex-basis: 100%;
  text-align: center;
  font-size: 11px;
  color: var(--text-leise);
}

kbd {
  display: inline-block;
  min-width: 22px;
  padding: 2px 5px;
  font-family: var(--schrift-text);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
  text-align: center;
  color: var(--tinte);
  background: var(--papier);
  border: 1px solid var(--tinte);
  border-bottom-width: 2px;
  border-radius: 0;
}

/* ---------- Kleinere Bildschirme ---------- */

@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .table { max-width: 640px; margin: 0 auto; }
  .side { flex-direction: row; flex-wrap: wrap; }
  .side > .panel { flex: 1 1 240px; }
  .moves { max-height: 168px; }
}

@media (max-width: 520px) {
  .app { padding-top: 20px; gap: 18px; }
  .side { flex-direction: column; }
  /* In der Spaltenrichtung würde flex-basis sonst die Höhe dehnen. */
  .side > .panel { flex: 0 0 auto; }
  .legend { gap: 6px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ==================== Steine, Hinweis, Regeln ==================== */

.player__stones {
  margin-left: auto;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--text-leise);
}

/* Hinweis als Stempel: Tintenrahmen, Versalien. */
.alert {
  display: inline-block;
  margin: 10px 0 0;
  padding: 0.15rem 0.5rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--tinte);
  background: transparent;
  border: 2px solid var(--tinte);
}

.alert[hidden] { display: none; }

.rules {
  margin: 0;
  padding-left: 18px;
  color: var(--text-leise);
  font-size: 13px;
}

.rules li + li { margin-top: 4px; }
