@font-face {
  font-family: 'mydigital';
  src: url('fonts/mydigital.ttf') format('truetype');
}
@font-face {
  font-family: 'Caveat';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../fonts/caveat-500.woff2') format('woff2');
}
@font-face {
  font-family: 'Caveat';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../fonts/caveat-700.woff2') format('woff2');
}

:root{
  --accent:#00e5ff;
  --accent-2:#ff4ade;
  --ok:#10b981;
  --danger:#ef4444;
  --bg:#071023;
  --card:#081227;
  --muted:#9aa6b2;
  --glow: 0 0 18px rgba(0,229,255,0.25), 0 0 40px rgba(255,74,170,0.06);
  font-family: 'Inter', ui-sans-serif, system-ui;
  --score-red:#ff2d2d;
  --sidebar-width: 240px;
}

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

html, body { height: 100%; }

body {
  min-height: 100vh;
  display: block;
  margin: 0;
  background: radial-gradient(1200px 600px at 10% 10%, #051023 0%, #021018 20%, #000814 80%), var(--bg);
  color: #e6f3ff;
}

.app {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 55px);
  max-width: max(1400px, calc(100vh - 110px + var(--sidebar-width) + 60px));
  margin: 12px auto 0;
}

.page-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.board {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  max-width: calc(100vh - 110px);
}

/* ======= Canvas ======= */
#kosCanvas {
  display: block;
  border-radius: 8px;
  cursor: crosshair;
}

/* ======= Startscreen ======= */
#startScreen {
  max-width: 400px;
  width: 100%;
  text-align: center;
  background: var(--card);
  padding: 24px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.03);
  box-shadow: 0 6px 28px rgba(2,6,23,0.6), 0 1px 0 rgba(255,255,255,0.02) inset;
  transform: scale(0);
  animation: popIn 0.5s forwards ease-out;
  margin: auto;
}

@keyframes popIn {
  0% { transform: scale(0); opacity:0; }
  80% { transform: scale(1.1); opacity:1; }
  100% { transform: scale(1); }
}

#startScreen select {
  display: block;
  width: 100%;
  margin: 6px 0 14px;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.08);
  background: #0c1a30;
  color: #e6f3ff;
  font-size: 15px;
}

#startScreen input {
  display: block;
  width: 100%;
  margin: 6px 0;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.08);
  background: #0c1a30;
  color: #e6f3ff;
  font-size: 15px;
}

/* ======= Card ======= */
.card{
  background: var(--card);
  border-radius: 12px;
  padding: 14px;
  border: 1px solid rgba(255,255,255,0.03);
  box-shadow: 0 6px 28px rgba(2,6,23,0.6), 0 1px 0 rgba(255,255,255,0.02) inset;
  margin: 0;
}

section.card{ margin-bottom:0; }
.app > section.card { flex: 0 0 auto; margin-bottom:12px; }

/* ======= Problem Row ======= */
.problem-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.problem-wrapper{
  display:flex;
  align-items:center;
  gap:6px;
  font-size:34px;
  flex:0 0 auto;
}

.controls-inline {
  display: flex;
  gap: 8px;
  align-items: center;
}

.coord-paren { font-weight:700; color:#e6f3ff; }
.coord-sep   { font-weight:700; color:var(--muted); margin:0 2px; }

.slot{
  width:42px;
  height:42px;
  border-radius:10px;
  background:linear-gradient(180deg,#fff,#fff);
  display:flex;
  align-items:center;
  justify-content:center;
  box-shadow: var(--glow);
  border:1px solid rgba(255,255,255,0.03);
  font-weight:700;
  font-size:22px;
  color:#000;
  overflow:hidden;
  position:relative;
}

.slot-viewport{
  overflow:hidden;
  height:100%;
  border-radius:10px;
  position:relative;
}

.slot-column{
  display:block;
  transition: transform 0.5s ease;
}

.slot-column .slot-item{
  height:42px;
  display:flex;
  align-items:center;
  justify-content:center;
  font-weight:700;
  font-size:20px;
  color:#000;
}

/* ======= Countdown ======= */
.countdown-box {
  font-weight: 700;
  color: var(--accent);
  font-size: 18px;
  min-width: 100px;
  text-align: center;
}

.shuffle-btn{
  position: relative;
  background: linear-gradient(180deg, rgba(0,0,0,0.2), rgba(255,255,255,0.02));
  border: 1px solid rgba(255,255,255,0.06);
  padding: 8px 12px;
  border-radius: 999px;
  height: 48px;
  width: 48px;
  cursor:pointer;
  font-weight:700;
  color: #fff;
  box-shadow: 0 6px 24px rgba(0,0,0,0.6);
}
.shuffle-btn:hover{ transform:translateY(-2px); }

.shuffle-btn::after{
  content:"";
  position:absolute;
  inset:-8px;
  border-radius:inherit;
  background:none;
  box-shadow:
    0 0 12px rgba(255,0,0,0.6),
    0 0 28px rgba(255,0,0,0.45),
    0 0 50px rgba(255,0,0,0.25);
  opacity:0;
  z-index:-1;
  pointer-events:none;
}

/* ======= Board + Info ======= */
.board-and-info {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  gap: 16px;
  align-items: stretch;
}

.game-width-full {
  width: 100%;
}

/* ======= Sidebar ======= */
aside.card{
  width: var(--sidebar-width);
  flex: 0 0 var(--sidebar-width);
  display: flex;
  flex-direction: column;
}

.sidebar-top { flex: 0 0 auto; }

.instructions{
  margin-top:auto;
  margin-bottom: 12px;
  color: var(--muted);
  font-size:13px;
  line-height:1.4;
}

/* ======= Player Toggle ======= */
.player-toggle{
  display:flex;
  gap:10px;
  align-items:center;
  background: rgba(255,255,255,0.01);
  padding:8px;
  border-radius:10px;
}

.player-toggle .name{
  padding:6px 10px;
  border-radius:5px;
  background: linear-gradient(180deg, rgba(255,255,255,0.01), rgba(255,255,255,0.01));
  font-weight:700;
  position:relative;
  cursor:pointer;
  transition: transform .12s, box-shadow .12s;
}

.player-toggle .name.active{
  color: #001;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  box-shadow: 0 6px 30px rgba(0,229,255,0.14), 0 0 20px rgba(255,74,170,0.08);
  transform: translateY(-2px);
}

/* ======= Scores ======= */
#scoreList{ flex:0 0 auto; }

.score-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  margin-bottom:10px;
  font-size:15px;
}

.score-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.score-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
  text-shadow: 0 0 4px var(--accent), 0 0 10px var(--accent-2);
}

.next-player-btn {
  background: linear-gradient(180deg, rgba(0,0,0,0.2), rgba(255,255,255,0.02));
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 999px;
  width: 28px;
  height: 28px;
  cursor: pointer;
  color: var(--muted);
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: color 0.15s, transform 0.1s;
}
.next-player-btn:hover {
  color: var(--accent);
  transform: translateY(-1px);
}

.score-row .player-name{
  font-size:15px;
  color:var(--muted);
  font-weight:600;
}

.score-row .player-name::before {
  content: '▸\00a0';
  visibility: hidden;
}

.score-row .player-name::after {
  content: '\00a0◂';
  visibility: hidden;
}

.score-row.active .player-name {
  color: var(--accent);
}

.score-row.active .player-name::before,
.score-row.active .player-name::after {
  visibility: visible;
  color: var(--accent-2);
}

.score-row .score-value{
  font-family:'mydigital', monospace;
  font-size:28px;
  letter-spacing:2px;
  color:var(--score-red);
  text-shadow:
    0 0 6px var(--score-red),
    0 0 12px rgba(255,45,45,0.7),
    0 0 22px rgba(255,45,45,0.5);
}

/* ======= Winner ======= */
#winnerDisplay, .winner-display {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
  text-shadow: 0 0 6px var(--accent), 0 0 12px var(--accent-2), 0 0 20px rgba(255,74,170,0.5);
  min-width: 0;
  animation: neonPulse 1.2s infinite alternate;
}

@keyframes neonPulse {
  0%   { text-shadow: 0 0 4px var(--accent), 0 0 10px var(--accent-2), 0 0 18px rgba(255,74,170,0.4); }
  50%  { text-shadow: 0 0 8px var(--accent), 0 0 18px var(--accent-2), 0 0 28px rgba(255,74,170,0.6); }
  100% { text-shadow: 0 0 6px var(--accent), 0 0 12px var(--accent-2), 0 0 20px rgba(255,74,170,0.5); }
}

/* ======= Pulse-Button ======= */
@keyframes arcadePulse {
  0%   { transform: scale(1);    box-shadow: 0 0 6px rgba(255,74,170,0.4), 0 0 14px rgba(255,74,170,0.3); }
  50%  { transform: scale(1.08); box-shadow: 0 0 14px rgba(255,74,170,0.9), 0 0 30px rgba(255,74,170,0.6); }
  100% { transform: scale(1);    box-shadow: 0 0 6px rgba(255,74,170,0.4), 0 0 14px rgba(255,74,170,0.3); }
}

.shuffle-btn.pulse {
  animation: arcadePulse 1.1s infinite ease-in-out;
}

.reset-btn-right {
  margin-left: auto;
  font-size: 22px;
  color: var(--muted);
}

.shuffle-btn.confirm {
  background: linear-gradient(180deg, rgba(239,68,68,0.4), rgba(239,68,68,0.15));
  border-color: rgba(239,68,68,0.5);
  color: #ef4444;
  font-size: 18px;
  animation: arcadePulse 0.8s infinite ease-in-out;
}

/* ======= Responsive ======= */
@media (max-width:800px){
  .app{padding:12px;}
  .problem-wrapper{font-size:28px;}
  .slot{width:38px;height:42px;}
  .slot-column .slot-item{height:42px;}
}

@media (min-width:900px){
  .board-and-info{
    gap:18px;
    align-items:stretch;
  }
}

@media (max-width:1140px){
  .app { padding:0 12px; }
}

/* ======= Tablet: Sidebar wird Score-Leiste ======= */
@media (max-width: 1024px) {
  .game-width-full { max-width: none; }

  .board-and-info {
    flex-direction: column;
    gap: 8px;
  }

  aside.card {
    width: 100%;
    flex: 0 0 auto;
    order: -1;
    padding: 8px 14px;
  }

  .sidebar-top {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
  }

  .sidebar-top > br { display: none; }

  .score-header { justify-content: center; }
  .score-title { font-size: 13px; }
  .next-player-btn { width: 22px; height: 22px; font-size: 11px; }

  #scoreList {
    display: flex;
    gap: 12px;
    justify-content: center;
  }

  .score-row {
    flex-direction: column;
    align-items: center;
    margin-bottom: 0;
    gap: 0;
  }

  .score-row .player-name { font-size: 12px; }

  .score-row .score-value {
    font-size: 22px;
    letter-spacing: 1px;
  }

  .instructions { display: none; }

  .board {
    max-width: 100%;
    max-height: none;
    overflow: visible;
    flex: 0 0 auto;
  }
}

/* ======= Smartphone ======= */
@media (max-width: 600px) {
  .app {
    height: auto;
    min-height: 0;
    padding: 0 6px;
    margin-top: 8px;
  }

  section.card { padding: 10px; }

  .problem-row { gap: 8px; }

  .problem-wrapper {
    font-size: 22px;
    gap: 4px;
  }

  .slot {
    width: 32px;
    height: 36px;
    border-radius: 8px;
  }

  .slot-column .slot-item {
    height: 36px;
    font-size: 16px;
  }

  .countdown-box { font-size: 14px; min-width: 70px; }

  #winnerDisplay, .winner-display {
    font-size: 16px;
    min-width: auto;
    margin-left: 8px;
  }

  .shuffle-btn {
    height: 40px;
    width: 40px;
    padding: 6px 10px;
  }

  .score-title { font-size: 11px; }
  #scoreList { gap: 8px; }
  .score-row .player-name { font-size: 10px; }
  .score-row .score-value { font-size: 16px; }

  aside.card { padding: 8px 12px; }

  .board { padding: 6px; }

  #kosCanvas { border-radius: 6px; }

  #qr-trigger { display: none !important; }
}

/* ======= Footer ======= */
.es-footer {
  text-align: center;
  padding: 18px 20px 14px;
  font-size: 0.85rem;
  color: var(--muted);
}
.es-footer a {
  color: var(--muted);
  text-decoration: none;
}
.es-footer a:hover {
  color: var(--accent);
}
