* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: Arial, sans-serif;
  background: #067cb3;
  color: #102033;
}

button,
input,
select,
textarea {
  font: inherit;
}

img {
  max-width: 100%;
  height: auto;
}

button {
  user-select: none;
}

.icon-btn {
  cursor: pointer;
}

#scene-root {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

#scene-root canvas {
  pointer-events: none;
}

.screen-panel,
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  z-index: 40;
  pointer-events: auto;
  background: rgba(3, 20, 36, 0.54);
}

.screen-panel::before,
.modal::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  backdrop-filter: blur(8px);
}

.screen-panel.hidden,
.modal.hidden,
.game-logo.hidden,
.turn-panel.hidden,
.continue-panel.hidden,
.hidden {
  display: none !important;
}

.panel-card,
.modal-card {
  position: relative;
  z-index: 2;
  width: min(540px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.97), rgba(247, 239, 222, 0.97));
  border: 1px solid rgba(255, 255, 255, 0.85);
  border-radius: 28px;
  padding: 28px;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.32);
}

.wide-card {
  width: min(760px, 100%);
}

#start-screen.screen-panel {
  padding: 20px;
  align-items: center;
}

#start-screen .wide-card[data-setup-step="units"] {
  height: calc(100vh - 40px);
  height: calc(100dvh - 40px);
  max-height: calc(100vh - 40px);
  max-height: calc(100dvh - 40px);
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  padding: 14px 24px 16px;
  align-content: stretch;
}

#start-screen .wide-card[data-setup-step="units"] .brand-block {
  margin-bottom: 8px;
}

#start-screen .wide-card[data-setup-step="units"] .brand-logo {
  max-width: 200px;
  max-height: 64px;
  margin-bottom: 4px;
}

#start-screen .wide-card[data-setup-step="units"] .admin-entry-btn {
  margin-top: 4px;
}

/* Tahta internetten yüklenemeyince (js/main.js) açılış ekranının üstünde duran uyarı.
   Soru Yönetimi (z-index 90) açıkken altında kalır; panel tahtaya ihtiyaç duymaz. */
.board-warning {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 16px;
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 8px 10px 8px 20px;
  border: 2px solid #e6a8a2;
  border-radius: 18px;
  background: #fdecea;
  color: #9b2219;
  font-size: 18px;
  font-weight: 800;
  line-height: 1.3;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.3);
  pointer-events: auto;
}

.board-warning.is-flash {
  animation: boardWarningFlash 0.5s ease;
}

@keyframes boardWarningFlash {
  0%, 100% { transform: translateX(-50%); }
  25% { transform: translateX(calc(-50% - 10px)); }
  75% { transform: translateX(calc(-50% + 10px)); }
}

.board-warning-btn {
  flex: 0 0 auto;
  min-height: 48px;
  padding: 10px 18px;
  border: 0;
  border-radius: 13px;
  background: #9b2219;
  color: #fff;
  font-size: 16px;
  font-weight: 900;
  cursor: pointer;
}

/* Uyarı görünürken açılış kartı aşağı kayar, uyarının altında kalmaz. */
:root.board-offline #start-screen.screen-panel {
  padding-top: 96px;
}

:root.board-offline #start-screen .panel-card,
:root.board-offline #start-screen .wide-card[data-setup-step="players"] {
  max-height: 100%;
}

:root.board-offline #start-screen .wide-card[data-setup-step="units"] {
  height: 100%;
  max-height: 100%;
}

@media (max-width: 720px) {
  .board-warning {
    font-size: 14px;
    gap: 10px;
    padding-left: 14px;
  }

  :root.board-offline #start-screen.screen-panel {
    padding-top: 112px;
  }
}

.brand-block {
  display: grid;
  justify-items: center;
  text-align: center;
  margin-bottom: 22px;
}

.brand-logo {
  display: block;
  max-width: 280px;
  max-height: 92px;
  width: auto;
  height: auto;
  margin: 0 auto 12px;
  object-fit: contain;
}

.brand-block p {
  max-width: 560px;
  margin-bottom: 0;
}

.admin-entry-btn {
  margin-top: 16px;
  min-height: 48px;
  border: 1px solid rgba(18, 82, 119, 0.2);
  border-radius: 999px;
  padding: 9px 18px;
  background: rgba(255, 255, 255, 0.76);
  color: #125277;
  font-size: 15px;
  font-weight: 900;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.admin-entry-btn:hover {
  transform: translateY(-1px);
  border-color: #1497d1;
  background: #fff;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  font-size: clamp(30px, 4vw, 50px);
  margin-bottom: 8px;
  color: #125277;
}

h2 {
  font-size: clamp(20px, 3vw, 30px);
  color: #173d51;
  line-height: 1.22;
}

p {
  line-height: 1.55;
  color: #405060;
}

.setup-step {
  display: none !important;
}

.wide-card[data-setup-step="grade"] #setup-step-grade,
.wide-card[data-setup-step="units"] #setup-step-units,
.wide-card[data-setup-step="players"] #setup-step-players {
  display: block !important;
}

.wide-card:not([data-setup-step="players"]):has(#grade-9:checked) #setup-step-grade,
.wide-card:not([data-setup-step="players"]):has(#grade-10:checked) #setup-step-grade,
.wide-card:not([data-setup-step="players"]):has(#grade-11:checked) #setup-step-grade,
.wide-card:not([data-setup-step="players"]):has(#grade-12:checked) #setup-step-grade {
  display: none !important;
}

.wide-card:not([data-setup-step="players"]):has(#grade-9:checked) #setup-step-units,
.wide-card:not([data-setup-step="players"]):has(#grade-10:checked) #setup-step-units,
.wide-card:not([data-setup-step="players"]):has(#grade-11:checked) #setup-step-units,
.wide-card:not([data-setup-step="players"]):has(#grade-12:checked) #setup-step-units {
  display: flex !important;
  flex-direction: column;
}

.wide-card[data-setup-step="players"] #setup-step-grade,
.wide-card[data-setup-step="players"] #setup-step-units {
  display: none !important;
}

#start-screen .wide-card[data-setup-step="units"] #setup-step-units {
  min-height: 0;
  height: 100%;
  display: flex !important;
  flex-direction: column;
  overflow: hidden;
}

#start-screen .wide-card[data-setup-step="units"] .setup-hint {
  margin: 0 0 8px;
}

#start-screen .wide-card[data-setup-step="units"] .setup-note {
  margin-bottom: 8px;
}

#start-screen .wide-card[data-setup-step="units"] .select-all-row {
  margin-bottom: 8px;
  padding: 10px 12px;
}

.grade-radios {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.grade-units {
  display: none;
}

.wide-card:has(#grade-9:checked) .grade-units[data-units-grade="9"],
.wide-card:has(#grade-10:checked) .grade-units[data-units-grade="10"],
.wide-card:has(#grade-11:checked) .grade-units[data-units-grade="11"],
.wide-card:has(#grade-12:checked) .grade-units[data-units-grade="12"] {
  display: grid;
  gap: 12px;
}

.setup-hint {
  margin-bottom: 14px;
  font-weight: 800;
  color: #1e5a78;
}

.setup-note {
  margin-top: -6px;
  margin-bottom: 14px;
  font-size: 14px;
  color: #5a7384;
}

.back-link {
  display: inline-flex;
  align-items: center;
  min-height: 48px;
  border: 0;
  background: transparent;
  color: #0d7aa8;
  font-weight: 800;
  padding: 0 14px 0 0;
  cursor: pointer;
  text-align: left;
}

#setup-step-units .back-link {
  align-self: flex-start;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.grade-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.choice-card {
  position: relative;
  z-index: 3;
  display: grid;
  border: 1px solid #c9dce8;
  border-radius: 22px;
  background: white;
  color: #125277;
  font-weight: 900;
  padding: 18px 14px;
  cursor: pointer;
  pointer-events: auto;
  box-shadow: 0 10px 22px rgba(18, 82, 119, 0.08);
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.grade-card {
  display: grid;
  justify-items: center;
  align-content: center;
  min-height: 158px;
  padding: 26px 10px 20px;
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 85%, rgba(255, 255, 255, 0.85) 0 3px, transparent 4px),
    radial-gradient(circle at 28% 78%, rgba(255, 255, 255, 0.65) 0 5px, transparent 6px),
    linear-gradient(145deg, #effaff, #e9f8ee);
}

.grade-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 6px;
  background: linear-gradient(90deg, #159bd2, #31c47e);
}

.grade-card::after {
  content: "";
  position: absolute;
  width: 82px;
  height: 82px;
  right: -32px;
  bottom: -38px;
  border: 13px solid rgba(20, 151, 209, 0.08);
  border-radius: 50%;
}

.grade-card:nth-child(2)::before {
  background: linear-gradient(90deg, #20aeb4, #64ca6c);
}

.grade-card:nth-child(3)::before {
  background: linear-gradient(90deg, #6a8ee8, #28b6b5);
}

.grade-card:nth-child(4)::before {
  background: linear-gradient(90deg, #e7983b, #e8667d);
}

.grade-card i {
  position: absolute;
  top: 16px;
  right: 15px;
  display: grid;
  place-items: center;
  width: 31px;
  height: 31px;
  border: 1px solid rgba(18, 82, 119, 0.1);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.76);
  color: #2496b3;
  font-size: 17px;
  font-style: normal;
  box-shadow: 0 5px 12px rgba(18, 82, 119, 0.08);
}

.grade-card span {
  display: block;
  font-size: 48px;
  line-height: 1;
  margin-bottom: 7px;
  color: #0f7fb3;
  text-shadow: 0 3px 0 rgba(255, 255, 255, 0.82);
}

.grade-card b {
  color: #125277;
  font-size: 17px;
  letter-spacing: 0.2px;
}

.choice-card:hover,
.grade-card:hover {
  transform: translateY(-3px);
  border-color: #36a7db;
  box-shadow: 0 16px 30px rgba(18, 132, 162, 0.18);
}

.grade-card.is-selected {
  border-color: #1497d1;
  background:
    radial-gradient(circle at 20% 85%, rgba(255, 255, 255, 0.9) 0 3px, transparent 4px),
    radial-gradient(circle at 28% 78%, rgba(255, 255, 255, 0.72) 0 5px, transparent 6px),
    linear-gradient(145deg, #e1f6ff, #dcf7e5);
  box-shadow: 0 0 0 4px rgba(20, 151, 209, 0.18), 0 16px 30px rgba(18, 132, 162, 0.16);
}

.select-all-row,
.unit-check {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
  overflow: hidden;
}

.select-all-row {
  margin-bottom: 12px;
  padding: 12px 14px;
  border-radius: 16px;
  background: linear-gradient(135deg, #e8f7ff, #e9fbef);
  border: 1px solid #9ad7ef;
  font-weight: 800;
  color: #125277;
}

.select-all-row input,
.unit-check input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  opacity: 0;
  cursor: pointer;
  pointer-events: auto;
  z-index: 2;
}

.select-all-row input:focus,
.unit-check input:focus {
  box-shadow: none;
}

.check-mark {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border-radius: 7px;
  border: 2px solid #7eb7d0;
  background: white;
  box-shadow: inset 0 1px 2px rgba(18, 82, 119, 0.08);
  position: relative;
}

.select-all-row input:checked + .check-mark,
.unit-check input:checked + .check-mark,
.select-all-row input:indeterminate + .check-mark {
  border-color: #1497d1;
  background: linear-gradient(135deg, #1497d1, #32c47d);
}

.select-all-row input:checked + .check-mark::after,
.unit-check input:checked + .check-mark::after,
.select-all-row input:indeterminate + .check-mark::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 3px;
  width: 6px;
  height: 11px;
  border: 2px solid white;
  border-top: 0;
  border-left: 0;
  transform: rotate(45deg);
}

.select-all-row input:indeterminate + .check-mark::after {
  left: 4px;
  top: 8px;
  width: 10px;
  height: 0;
  border-right: 0;
  transform: none;
}

.unit-theme-list {
  display: grid;
  gap: 12px;
  max-height: 38vh;
  overflow: auto;
  padding-right: 4px;
  margin-bottom: 16px;
}

#start-screen .wide-card[data-setup-step="units"] .unit-theme-list {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  margin-bottom: 0;
}

.units-continue-bar {
  position: relative;
  z-index: 3;
  flex: 0 0 auto;
  flex-shrink: 0;
  margin-top: 10px;
  padding-top: 12px;
  background: linear-gradient(180deg, rgba(247, 239, 222, 0), rgba(247, 239, 222, 0.97) 18%, rgba(247, 239, 222, 0.97));
}

.theme-group {
  border-radius: 20px;
  padding: 14px;
  background: white;
  border: 1px solid #d5e6ef;
}

#start-screen .wide-card[data-setup-step="units"] .theme-group {
  padding: 10px 12px;
}

#start-screen .wide-card[data-setup-step="units"] .theme-group h3 {
  margin-bottom: 8px;
}

#start-screen .wide-card[data-setup-step="units"] .unit-check {
  padding: 10px 12px;
}

.theme-group h3 {
  margin: 0 0 10px;
  font-size: 13px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  color: #0f7fb3;
}

.theme-etkilesim {
  border-color: #9ad7ef;
  background: linear-gradient(180deg, #f3fbff, #fff);
}

.theme-etkilesim h3 {
  color: #0d7aa8;
}

.theme-cesitlilik {
  border-color: #b7e7c8;
  background: linear-gradient(180deg, #f3fdf6, #fff);
}

.theme-cesitlilik h3 {
  color: #1b8a52;
}

.theme-surdurulebilirlik {
  border-color: #f6d59a;
  background: linear-gradient(180deg, #fff8eb, #fff);
}

.theme-surdurulebilirlik h3 {
  color: #c67a12;
}

.theme-unites h3 {
  display: none;
}

.unit-check-list {
  display: grid;
  gap: 8px;
}

.unit-check {
  padding: 12px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid #d7e6ef;
  font-weight: 800;
  color: #173d51;
}

.unit-check:hover {
  border-color: #36a7db;
}

.unit-check.is-checked {
  border-color: #32c47d;
  background: rgba(50, 196, 125, 0.1);
}

#continue-units-btn {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 13px 20px;
  font-size: 16px;
  border-radius: 16px;
  box-shadow: 0 12px 28px rgba(18, 132, 162, 0.26);
}

.setup-grid {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 18px;
  align-items: start;
  margin-bottom: 22px;
}

label {
  display: grid;
  gap: 8px;
  font-weight: 800;
  color: #25445a;
}

select,
input,
textarea {
  width: 100%;
  border: 1px solid #c9dce8;
  border-radius: 16px;
  padding: 14px 15px;
  outline: none;
  background: white;
}

textarea {
  resize: vertical;
  line-height: 1.45;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #36a7db;
  box-shadow: 0 0 0 4px rgba(54, 167, 219, 0.16);
}

.name-fields {
  display: grid;
  gap: 10px;
}

/* Dokunmatik tahtada düğmeler en az 48 px yüksekliktedir. */
.primary-btn,
.secondary-btn,
.plain-btn,
.danger-btn {
  min-height: 48px;
}

.primary-btn {
  border: 0;
  border-radius: 17px;
  background: linear-gradient(135deg, #1497d1, #32c47d);
  color: white;
  font-weight: 900;
  padding: 14px 20px;
  cursor: pointer;
  box-shadow: 0 15px 32px rgba(18, 132, 162, 0.28);
  transition: transform 0.15s ease, filter 0.15s ease, opacity 0.15s ease;
}

.primary-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.04);
}

.primary-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

#start-game-btn {
  width: 100%;
}

/* Oyuncu kurulum adımı */
#start-screen .wide-card[data-setup-step="players"] {
  width: min(860px, 100%);
  max-height: calc(100dvh - 40px);
  padding: 24px 30px 28px;
  /* 6 oyuncuda içerik karta sığmazsa kart kayar; "Oyuna Başla" erişilir kalır. */
  overflow: hidden auto;
  overscroll-behavior: contain;
  /* Süs halkaları arka plan katmanıdır: taşan öğe olmadıkları için kaydırma alanını uzatmazlar. */
  background:
    radial-gradient(circle at calc(100% - 40px) 199px, transparent 114.5px, rgba(20, 151, 209, 0.055) 115px 145px, transparent 145.5px),
    radial-gradient(circle at -10px 100%, rgba(50, 196, 125, 0.07) 85px, transparent 85.5px),
    radial-gradient(circle at 8% 18%, rgba(20, 151, 209, 0.12) 0 4px, transparent 5px),
    radial-gradient(circle at 94% 72%, rgba(50, 196, 125, 0.13) 0 5px, transparent 6px),
    linear-gradient(145deg, rgba(255, 255, 255, 0.98), rgba(247, 245, 226, 0.98));
}

#start-screen .wide-card[data-setup-step="players"] .brand-block {
  grid-template-columns: 1fr auto;
  justify-items: start;
  align-items: center;
  margin-bottom: 10px;
  border-bottom: 1px solid rgba(18, 82, 119, 0.1);
  padding-bottom: 12px;
}

#start-screen .wide-card[data-setup-step="players"] .brand-logo {
  max-width: 184px;
  max-height: 62px;
  margin: 0;
}

#start-screen .wide-card[data-setup-step="players"] .admin-entry-btn {
  margin: 0;
}

.players-step-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}

.setup-step-badge {
  padding: 6px 11px;
  border-radius: 999px;
  background: rgba(18, 82, 119, 0.08);
  color: #4d7082;
  font-size: 12px;
  font-weight: 900;
}

.players-setup-heading {
  margin-bottom: 14px;
}

.players-setup-heading h1 {
  margin: 0;
  font-size: clamp(26px, 4vw, 38px);
  line-height: 1.08;
}

.topic-ticket {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  padding: 10px 13px;
  border: 1px solid #a9ddef;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(228, 247, 255, 0.94), rgba(235, 252, 239, 0.94));
}

.topic-ticket-icon,
.topic-ticket-check {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 11px;
  background: white;
  color: #0c82b5;
  font-size: 20px;
  font-weight: 900;
}

.topic-ticket-check {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #32c47d;
  color: white;
  font-size: 15px;
}

.topic-ticket small,
.topic-ticket strong {
  display: block;
}

.topic-ticket small {
  margin-bottom: 2px;
  color: #658191;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.7px;
  text-transform: uppercase;
}

.topic-ticket strong {
  color: #174b66;
  font-size: 14px;
}

.players-setup-grid {
  grid-template-columns: 210px 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

.player-count-card,
.player-names-card {
  min-width: 0;
  padding: 15px;
  border: 1px solid #d5e6ef;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 9px 24px rgba(18, 82, 119, 0.07);
}

.player-count-card label,
.player-names-title span {
  color: #25445a;
  font-weight: 900;
}

.player-count-card select {
  margin-top: 8px;
  min-height: 52px;
  padding: 12px 13px;
  border-radius: 13px;
  font-size: 17px;
  font-weight: 800;
}

.player-names-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.player-names-title small {
  color: #607885;
  font-size: 13px;
}

.players-setup-grid .name-fields {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.players-setup-grid .name-fields label {
  gap: 5px;
  color: #456375;
  font-size: 14px;
}

.player-name-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Grup rozeti: piyonun rengi ve üstündeki numara. */
.player-color-dot {
  display: inline-grid;
  place-items: center;
  width: 1.5em;
  height: 1.5em;
  border-radius: 50%;
  flex: none;
  font-size: 0.82em;
  font-weight: 1000;
  line-height: 1;
  letter-spacing: 0;
  box-shadow: 0 0 0 1px rgba(16, 32, 51, 0.32);
}

.players-setup-grid .name-fields input {
  min-height: 48px;
  padding: 12px 13px;
  border-radius: 13px;
  color: #173d51;
  font-size: 18px;
  font-weight: 800;
}

.players-setup-grid .name-fields input::placeholder {
  color: #8da1ad;
  font-weight: 700;
  opacity: 1;
}

.players-setup-grid .name-fields input.is-invalid {
  border-color: #c9372c;
  box-shadow: 0 0 0 4px rgba(201, 55, 44, 0.16);
}

/* Ad sınırı ve aynı ad uyarısı; hata (aynı ad) oyunun başlamasını durdurur. */
.player-name-warning {
  margin: 10px 0 0;
  padding: 9px 12px;
  border: 1px solid #e6c766;
  border-radius: 12px;
  background: #fff6d6;
  color: #6b4d00;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.35;
}

.player-name-warning.is-error {
  border-color: #e6a8a2;
  background: #fdecea;
  color: #9b2219;
}

#start-screen .wide-card[data-setup-step="players"] #start-game-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 52px;
  border-radius: 18px;
  font-size: 17px;
}

#start-screen .wide-card[data-setup-step="players"] #start-game-btn b {
  font-size: 22px;
  line-height: 1;
  transition: transform 0.15s ease;
}

#start-screen .wide-card[data-setup-step="players"] #start-game-btn:hover b {
  transform: translateX(4px);
}


.secondary-btn {
  border: 0;
  border-radius: 17px;
  background: linear-gradient(135deg, #ff9d35, #e54343);
  color: white;
  font-weight: 900;
  padding: 14px 20px;
  cursor: pointer;
  box-shadow: 0 15px 32px rgba(184, 67, 36, 0.24);
  transition: transform 0.15s ease, filter 0.15s ease, opacity 0.15s ease;
}

.secondary-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.04);
}

.plain-btn,
.danger-btn {
  border-radius: 13px;
  padding: 10px 14px;
  background: white;
  color: #31566c;
  border: 1px solid #c9dce8;
  font-weight: 900;
  cursor: pointer;
}

.danger-btn,
.danger-text {
  color: #b52e35;
  border-color: #efb4b7;
}

.admin-modal {
  z-index: 90;
  padding: 16px;
}

.admin-card {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  width: min(1180px, 100%);
  height: min(820px, calc(100vh - 32px));
  overflow: hidden;
  border-radius: 26px;
  border: 1px solid rgba(255, 255, 255, 0.82);
  background: #f5f9fb;
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.38);
}

.admin-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 24px 18px;
  background: linear-gradient(135deg, #ecf9ff, #eefbf3);
  border-bottom: 1px solid #d6e7ef;
}

.admin-header .modal-tag {
  justify-self: start;
  margin-bottom: 9px;
}

.admin-header h1 {
  margin: 0 0 4px;
  font-size: clamp(25px, 3vw, 38px);
}

.admin-header p {
  margin: 0;
  font-size: 14px;
}

.admin-close-btn {
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  border: 1px solid #c9dce8;
  background: white;
  color: #31566c;
  font-size: 30px;
  line-height: 1;
  cursor: pointer;
}

.admin-toolbar {
  display: grid;
  grid-template-columns: 150px minmax(240px, 1fr) minmax(220px, 0.8fr);
  gap: 12px;
  padding: 14px 24px;
  border-bottom: 1px solid #d6e7ef;
  background: #fff;
}

.admin-toolbar label,
.admin-editor-panel label {
  font-size: 12px;
  gap: 6px;
}

.admin-toolbar select,
.admin-toolbar input {
  padding: 10px 12px;
  border-radius: 12px;
}

.admin-workspace {
  display: grid;
  grid-template-columns: minmax(330px, 0.9fr) minmax(390px, 1.1fr);
  min-height: 0;
}

.admin-list-panel,
.admin-editor-panel {
  min-height: 0;
  padding: 18px 20px;
}

.admin-list-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border-right: 1px solid #d6e7ef;
  background: #eef5f8;
}

.admin-list-heading,
.admin-editor-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.admin-list-heading > div {
  display: grid;
  gap: 3px;
}

.admin-list-heading b {
  color: #173d51;
}

.admin-list-heading span {
  color: #638092;
  font-size: 12px;
  font-weight: 800;
}

.admin-list-heading .primary-btn {
  flex: 0 0 auto;
  padding: 10px 13px;
  border-radius: 13px;
  font-size: 13px;
}

.admin-question-list {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 0;
  overflow-y: auto;
  padding-right: 5px;
}

.admin-question-item {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 10px;
  width: 100%;
  padding: 11px;
  text-align: left;
  border: 1px solid #d3e2e9;
  border-radius: 15px;
  background: #fff;
  color: #244558;
  cursor: pointer;
}

.admin-question-item:hover,
.admin-question-item.is-active {
  border-color: #20a3d2;
  box-shadow: 0 0 0 3px rgba(32, 163, 210, 0.1);
}

.admin-question-item.is-active {
  background: #f2fbff;
}

.admin-question-number {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: #e3f5fc;
  color: #0d7aa8;
  font-size: 12px;
  font-weight: 900;
}

.admin-question-copy {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.admin-question-copy b {
  overflow: hidden;
  font-size: 13px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-question-copy small {
  overflow: hidden;
  color: #6c8492;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-editor-panel {
  display: grid;
  align-content: start;
  gap: 12px;
  min-width: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: #fff;
}

.admin-editor-heading {
  margin-bottom: 0;
}

.admin-editor-heading h2 {
  margin: 3px 0 0;
  font-size: 22px;
}

.admin-eyebrow {
  color: #0d7aa8;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.7px;
  text-transform: uppercase;
}

.admin-editor-panel textarea {
  padding: 11px 12px;
  border-radius: 13px;
}

.admin-answer-type {
  display: grid;
  gap: 7px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.admin-answer-type legend {
  margin: 0 0 7px;
  padding: 0;
  color: #244558;
  font-size: 12px;
  font-weight: 800;
}

.admin-answer-type-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  min-width: 0;
  padding: 4px;
  border: 1px solid #c9dce8;
  border-radius: 14px;
  background: #f1f7fa;
}

.admin-answer-type label {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 40px;
  padding: 9px 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: #31566c;
  font-weight: 900;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.admin-answer-type label:has(input:checked) {
  border-color: #20a3d2;
  background: #fff;
  color: #0d729c;
  box-shadow: 0 3px 10px rgba(26, 120, 158, 0.12);
}

.admin-answer-type input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  padding: 0;
  opacity: 0;
  pointer-events: none;
}

.admin-answer-type label:has(input:focus-visible) {
  outline: 3px solid rgba(54, 167, 219, 0.22);
  outline-offset: 1px;
}

.admin-answer-type:has(input[value="pdf"]:checked) + #admin-answer-text-fields {
  display: none !important;
}

.admin-answer-type:has(input[value="pdf"]:checked) ~ #admin-answer-pdf-fields {
  display: grid !important;
}

.admin-answer-type:has(input[value="text"]:checked) ~ #admin-answer-pdf-fields {
  display: none !important;
}

.admin-file-field input[type="file"] {
  padding: 9px;
  border-style: dashed;
  border-width: 2px;
  background: #f5fbfe;
  cursor: pointer;
}

.admin-file-field input[type="file"]::file-selector-button {
  margin-right: 10px;
  border: 0;
  border-radius: 10px;
  padding: 8px 11px;
  background: #167fab;
  color: white;
  font-weight: 900;
  cursor: pointer;
}

.admin-media-row {
  display: grid;
  grid-template-columns: minmax(190px, 0.75fr) minmax(250px, 1.25fr);
  align-items: start;
  gap: 12px;
  min-width: 0;
}

.admin-preview-stack {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.admin-file-prompt {
  display: flex;
  flex-direction: column;
  gap: 10px;
  color: #2e5d74;
  font-size: 11px;
}

.admin-media-preview {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 170px;
  min-height: 0;
  overflow: hidden;
  border: 1px solid #cadde6;
  border-radius: 15px;
  background: #142a3a;
  color: #d7e7ef;
}

.admin-media-preview img,
.admin-media-preview iframe {
  width: 100%;
  height: 100%;
  border: 0;
  object-fit: contain;
  background: white;
}

.admin-media-preview > span {
  max-width: 80%;
  text-align: center;
  line-height: 1.5;
  font-size: 12px;
  font-weight: 800;
}

.admin-current-file {
  overflow: hidden;
  margin-top: 0;
  color: #607b8b;
  font-size: 11px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-editor-panel label small {
  color: #6c8492;
  font-weight: 600;
}

.admin-status {
  min-height: 19px;
  color: #577180;
  font-size: 13px;
  font-weight: 800;
}

.admin-status.success {
  color: #167444;
}

.admin-status.error {
  color: #b52e35;
}

.admin-form-actions {
  display: flex;
  gap: 10px;
}

.admin-form-actions .primary-btn {
  flex: 1;
}

@media (max-width: 980px) {
  .admin-media-row {
    grid-template-columns: 1fr;
  }

  .admin-media-preview {
    height: 165px;
  }
}

.admin-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
  border-top: 1px solid #d6e7ef;
  background: #f9fcfd;
}

.admin-footer span {
  color: #69808d;
  font-size: 12px;
  font-weight: 700;
}

/* Tüm düzenlemeleri silen düğme solda durur: sağdaki "Kaydet / Temizle" ile karışmaz. */
.admin-footer .plain-btn {
  order: -1;
  min-height: 48px;
  padding: 10px 16px;
  font-size: 14px;
}

.admin-empty-state {
  padding: 28px 18px;
  border: 1px dashed #b8cdd7;
  border-radius: 16px;
  color: #66808e;
  text-align: center;
  line-height: 1.5;
  background: rgba(255, 255, 255, 0.55);
}

.pause-card {
  text-align: center;
  width: min(460px, 100%);
}

.pause-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 22px;
}

.pause-actions #pause-resume-btn,
.pause-actions #autosave-resume-btn,
.pause-actions #autosave-dismiss-btn {
  grid-column: 1 / -1;
  width: 100%;
}

.pause-actions #pause-resume-btn {
  padding: 18px 20px;
  font-size: 18px;
}

.pause-actions .pause-save-btn,
.pause-actions .sound-toggle-btn,
.pause-actions .pause-finish-btn,
.pause-actions .pause-restart-btn {
  padding: 14px 12px;
  font-size: 15px;
}

/* Oyunu kapatan düğmeler "Devam Et"ten uzakta, ayrı bir bölmede durur. */
.pause-danger-zone {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 14px;
  padding-top: 18px;
  border-top: 2px dashed rgba(21, 83, 113, 0.18);
}

.pause-confirm {
  margin-top: 20px;
  padding: 18px;
  border: 2px solid #efb4b7;
  border-radius: 20px;
  background: #fff5f3;
}

.pause-confirm h3 {
  margin: 0 0 8px;
  color: #8f2329;
  font-size: 21px;
}

.pause-confirm p {
  margin: 0 0 16px;
  color: #5b3a3a;
  font-weight: 700;
  line-height: 1.45;
}

.pause-confirm-actions {
  display: grid;
  gap: 14px;
}

.pause-confirm-actions button {
  width: 100%;
  padding: 15px 16px;
  font-size: 16px;
}

.secondary-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.pause-status {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 13px;
  background: #e6f7ee;
  color: #1c6b45;
  font-weight: 800;
  line-height: 1.4;
}

.pause-status.is-error {
  background: #fdecec;
  color: #b52e35;
}

.saved-games {
  margin-top: 18px;
  padding: 14px;
  border: 1px solid #d5e6ef;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.82);
  text-align: left;
}

.saved-games h2 {
  margin-bottom: 10px;
  font-size: 16px;
  color: #25445a;
}

.saved-games-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
  max-height: 210px;
  overflow-y: auto;
}

.saved-games-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid #dbe9f1;
  border-radius: 14px;
  background: white;
}

.saved-game-info {
  flex: 1;
  min-width: 0;
}

.saved-game-info b,
.saved-game-info small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.saved-game-info b {
  color: #174b66;
  font-size: 14px;
}

.saved-game-info small {
  margin-top: 2px;
  color: #66808e;
  font-size: 12px;
}

.saved-games-list .primary-btn {
  padding: 10px 14px;
  font-size: 14px;
  white-space: nowrap;
}

.winner-ranking {
  display: grid;
  gap: 6px;
  margin: 0 auto 24px;
  padding: 0;
  max-width: 440px;
  list-style: none;
  text-align: left;
}

.winner-ranking li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid #dbe9f1;
  font-weight: 800;
  color: #25445a;
}

.winner-ranking li.is-first {
  border-color: #f2bd2c;
  background: #fff7dc;
}

.winner-ranking .rank-no {
  min-width: 28px;
  color: #1e5a78;
}

.winner-ranking .rank-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.winner-ranking .rank-place {
  color: #66808e;
  font-size: 14px;
}

.winner-ranking .rank-score {
  display: inline-flex;
  gap: 8px;
  min-width: 78px;
  justify-content: flex-end;
  font-size: 14px;
  white-space: nowrap;
}

.winner-ranking .rank-score .is-correct {
  color: #1c7a4a;
}

.winner-ranking .rank-score .is-wrong {
  color: #b52e35;
}

.winner-confetti {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  pointer-events: none;
  container-type: size;
}

.winner-confetti i {
  position: absolute;
  top: -30px;
  width: 12px;
  height: 20px;
  border-radius: 3px;
  opacity: 0;
  animation: confettiFall 4s linear 3 both;
}

#winner-screen.is-celebrating .winner-card {
  animation: winnerPop 0.7s cubic-bezier(0.2, 1.3, 0.4, 1) both;
}

#winner-screen.is-celebrating .winner-badge {
  animation: winnerBadgeFloat 1.5s ease-in-out 0.7s infinite alternate;
}

@media (prefers-reduced-motion: reduce) {
  .winner-confetti {
    display: none;
  }

  #winner-screen.is-celebrating .winner-card,
  #winner-screen.is-celebrating .winner-badge,
  .turn-badge.is-new {
    animation: none;
  }
}

/* Menü açıkken arkadaki zar, kart karıştırma ve süre uyarısı da durur. */
body.is-paused .dice-box.rolling .dice-face,
body.is-paused .dice-box.rolling .dice-arrows,
body.is-paused .modal.chance-picker .event-card::before,
body.is-paused .modal.chance-picker .event-card::after,
body.is-paused .question-timer.is-urgent,
body.is-paused .question-area:has(.question-timer.is-urgent) .question-media-shell {
  animation-play-state: paused;
}

.game-logo {
  position: fixed;
  left: 82px;
  top: 14px;
  z-index: 24;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 54px;
  pointer-events: auto;
}

.game-logo-img {
  display: block;
  flex: 0 0 auto;
  height: 60px;
  width: auto;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.3));
  pointer-events: none;
}

.icon-btn {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  background: rgba(5, 63, 100, 0.72);
  color: white;
  font-size: 29px;
  font-weight: 900;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
}

/* Menü düğmesi soru ekranının (30) ve bilgi kartlarının (40) üstünde, menünün (60) altındadır. */
.menu-btn {
  position: fixed;
  left: 16px;
  top: 14px;
  z-index: 45;
}

#pause-modal {
  z-index: 60;
}

/* Açılış gezisinde sağ altta durur; geziyi atlayıp ilk oyuncunun sırasına geçer. */
.tour-skip-btn {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 15;
  min-width: 96px;
  min-height: 54px;
  padding: 10px 24px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 999px;
  background: rgba(5, 63, 100, 0.72);
  color: white;
  font-size: 22px;
  font-weight: 800;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
}

/* Soru ekranında düğme başlık şeridinin soluna, kendisine ayrılan boşluğa oturur.
   Dokunma hedefi 48 px olsun diye 42 px'lik şeritten üstte ve altta 3'er px taşar. */
.turn-panel.question-mode ~ .menu-btn {
  left: calc(clamp(6px, 1vw, 14px) + 8px);
  top: calc(clamp(6px, 1vw, 14px) - 3px);
  width: 48px;
  height: 48px;
  border-radius: 13px;
  background: rgba(5, 63, 100, 0.94);
  font-size: 24px;
}

.turn-badge {
  --turn-color: #278cff;
  position: fixed;
  left: 50%;
  top: 14px;
  z-index: 13;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: clamp(8px, 0.8vw, 14px);
  min-height: 54px;
  max-width: calc(100vw - 552px);
  padding: 6px clamp(16px, 1.6vw, 28px);
  border: 4px solid var(--turn-color);
  border-radius: 999px;
  background: rgba(255, 252, 242, 0.96);
  color: #173d51;
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.22);
  pointer-events: none;
}

.turn-badge small {
  color: #1e5a78;
  font-size: clamp(13px, 1.1vw, 20px);
  font-weight: 1000;
  letter-spacing: 1.2px;
}

.turn-badge .player-color-dot {
  font-size: clamp(15px, 1.35vw, 26px);
}

.turn-badge b {
  min-width: 0;
  overflow: hidden;
  font-size: clamp(22px, 2.2vw, 40px);
  font-weight: 1000;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.turn-badge.is-new {
  animation: turnBadgePulse 0.9s ease-out;
}

@media (max-width: 999px) {
  .turn-badge small {
    display: none;
  }
}

.youtube-play-link {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  min-width: 54px;
  min-height: 54px;
  cursor: pointer;
}

.youtube-play-mark {
  width: 38px;
  height: 27px;
  flex: 0 0 auto;
  overflow: visible;
  filter: drop-shadow(0 4px 5px rgba(0, 0, 0, 0.25));
}

.youtube-play-bg {
  fill: #ff0033;
}

.youtube-play-triangle {
  fill: #fff;
}


.hud-badges {
  position: fixed;
  right: 18px;
  top: 18px;
  z-index: 13;
  display: grid;
  gap: 8px;
  justify-items: end;
}

.round-badge,
.topic-badge {
  min-width: 104px;
  text-align: center;
  padding: 12px 16px;
  border-radius: 18px;
  color: white;
  font-size: clamp(16px, 1.35vw, 30px);
  font-weight: 1000;
  letter-spacing: 0.8px;
  background: linear-gradient(135deg, rgba(14, 126, 178, 0.92), rgba(45, 190, 118, 0.92));
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.22);
}

.topic-badge {
  max-width: clamp(260px, 20vw, 480px);
  font-size: clamp(13px, 1.05vw, 24px);
  letter-spacing: 0.2px;
  line-height: 1.3;
  background: linear-gradient(135deg, rgba(16, 90, 132, 0.94), rgba(18, 151, 209, 0.94));
}

.info-image {
  width: min(260px, 80%);
  height: 145px;
  object-fit: cover;
  display: block;
  margin: 14px auto 14px;
  border-radius: 22px;
  /* box-shadow: 0 16px 32px rgba(0, 0, 0, 0.22); */
}

.continue-panel {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: center;
  width: max-content;
  max-width: calc(100% - 28px);
  padding: 5px;
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: 13px;
  background: linear-gradient(180deg, #f5f1e5, #e6e3d5);
  box-shadow: 0 4px 12px rgba(0, 48, 67, 0.16);
}

.continue-panel .primary-btn {
  padding: 12px 24px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 8px;
  background: linear-gradient(135deg, #109db6, #22b987);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
}

.turn-panel {
  position: fixed;
  left: 50%;
  top: 50%;
  width: min(440px, calc(100% - 32px));
  transform: translate(-50%, -50%);
  z-index: 18;
  filter: drop-shadow(0 22px 42px rgba(0, 0, 0, 0.35));
  transition: left 0.45s ease, top 0.45s ease, width 0.45s ease, transform 0.45s ease, opacity 0.25s ease;
}

/* Zar paneli odaktaki kareyi ve piyonu örtmez: dik ekranda alta, yatay ekranda sağa yanaşır.
   Tahta da odağı açıkta kalan alanın ortasına kaydırır (ui.syncBoardView → board.setView).
   Panel yerine geçişsiz oturur; böylece ölçülen konumu son konumudur. */
.turn-panel:not(.compact):not(.question-mode) {
  top: calc(100% - 16px);
  transform: translate(-50%, -100%);
  transition: opacity 0.25s ease;
}

@media (orientation: landscape) {
  .turn-panel:not(.compact):not(.question-mode) {
    left: calc(100% - clamp(16px, 2.5vw, 56px));
    top: 50%;
    transform: translate(-100%, -50%);
  }
}

/* Açılış gezisinden sonra zar paneli birden belirmez: yanaştığı kenardan süzülüp yavaşça görünür.
   `translate` ayrı bir özelliktir; panelin `transform` ile oturduğu yeri bozmaz. */
.turn-panel.is-soft-in {
  animation: turnPanelSoftIn 1.1s cubic-bezier(0.22, 0.8, 0.3, 1) 0.2s both;
}

@keyframes turnPanelSoftIn {
  from {
    opacity: 0;
    translate: 36px 0;
  }

  to {
    opacity: 1;
    translate: 0 0;
  }
}

@media (orientation: portrait) {
  @keyframes turnPanelSoftIn {
    from {
      opacity: 0;
      translate: 0 36px;
    }

    to {
      opacity: 1;
      translate: 0 0;
    }
  }
}

/* Bilgi paneli ekranın altında durur: odaktaki kare ve üstündeki piyonlar açıkta kalır. */
.turn-panel.compact {
  top: calc(100% - 24px);
  width: min(360px, calc(100% - 32px));
  transform: translate(-50%, -100%);
}

.turn-panel.question-mode {
  inset: 0;
  z-index: 30;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-height: none;
  padding: clamp(6px, 1vw, 14px);
  transform: none;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  background: rgba(5, 31, 47, 0.94);
  filter: none;
  transition: none;
}

.turn-panel.question-mode .turn-header {
  min-height: 42px;
  font-size: clamp(19px, 2.2vw, 27px);
}

.turn-panel.question-mode .turn-body {
  min-height: 0;
  max-height: none;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto minmax(0, 1fr);
  padding: clamp(8px, 1vw, 15px);
}

.turn-panel.question-mode .turn-header {
  width: calc(100% - 128px);
  text-align: center;
}

.turn-panel.question-mode .turn-player {
  min-height: 23px;
  margin-bottom: 3px;
  padding: 3px 10px;
  font-size: clamp(15px, 1.2vw, 21px);
}

/* Soru görünürken oyuncu satırı, sayaçla aynı hizadaki büyük kopyasında durur;
   böylece ayrı bir satır soru görselinden yer almaz. Cevap açılınca satır geri gelir. */
.turn-panel.question-mode:not(:has(.question-area.answer-mode)) #turn-player {
  display: none;
}

.turn-panel.question-mode:not(:has(.question-area.answer-mode)) .question-area {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.turn-panel.question-mode .turn-player.question-player {
  justify-self: center;
  min-width: 0;
  max-width: 100%;
  margin: 0;
  padding: 0.18em 0.7em;
  overflow: hidden;
  background: rgba(18, 83, 117, 0.12);
  font-size: clamp(17px, 1.7vw, 40px);
  white-space: nowrap;
}

.turn-panel.question-mode .turn-message {
  min-height: auto;
  margin-bottom: 4px;
  font-size: 12px;
}

.turn-panel.question-mode .turn-message:empty {
  display: none;
}

.turn-header {
  width: calc(100% - 44px);
  margin: 0 auto -2px;
  min-height: 55px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 20px 20px 10px 10px;
  background: linear-gradient(180deg, #1ba5df, #0875ae);
  border: 2px solid rgba(255, 255, 255, 0.45);
  color: white;
  font-size: 32px;
  font-weight: 1000;
  letter-spacing: 1px;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.18);
}

.turn-body {
  background: linear-gradient(180deg, rgba(255, 247, 230, 0.97), rgba(239, 221, 189, 0.97));
  border: 3px solid rgba(255, 255, 255, 0.74);
  border-radius: 26px;
  padding: 26px 26px 22px;
  text-align: center;
}

.turn-player {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 32px;
  padding: 6px 13px;
  margin-bottom: 14px;
  border-radius: 999px;
  background: rgba(18, 83, 117, 0.09);
  color: #173d51;
  font-size: 22px;
  font-weight: 900;
}

.turn-player-dot {
  font-size: 0.72em;
}

.dice-box {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 142px;
}

.dice-face {
  width: 92px;
  height: 92px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 9px;
  padding: 13px;
  border-radius: 20px;
  background: linear-gradient(145deg, #ffffff, #d6d0c4);
  box-shadow: inset 0 3px 7px rgba(255, 255, 255, 0.9), inset 0 -8px 14px rgba(0, 0, 0, 0.13), 0 16px 26px rgba(0, 0, 0, 0.23);
  transform: rotate(-12deg);
}

.dice-face span {
  opacity: 0;
  border-radius: 50%;
  background: #151515;
  box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.25);
}

.face-1 span:nth-child(5),
.face-2 span:nth-child(1),
.face-2 span:nth-child(9),
.face-3 span:nth-child(1),
.face-3 span:nth-child(5),
.face-3 span:nth-child(9),
.face-4 span:nth-child(1),
.face-4 span:nth-child(3),
.face-4 span:nth-child(7),
.face-4 span:nth-child(9),
.face-5 span:nth-child(1),
.face-5 span:nth-child(3),
.face-5 span:nth-child(5),
.face-5 span:nth-child(7),
.face-5 span:nth-child(9),
.face-6 span:nth-child(1),
.face-6 span:nth-child(3),
.face-6 span:nth-child(4),
.face-6 span:nth-child(6),
.face-6 span:nth-child(7),
.face-6 span:nth-child(9) {
  opacity: 1;
}

.dice-box.rolling .dice-face {
  animation: diceSpin 0.7s linear infinite;
}

.dice-arrows {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  font-size: 122px;
  color: rgba(21, 83, 113, 0.28);
  pointer-events: none;
  animation: arrowTurn 2.2s linear infinite;
}

.dice-box.rolling .dice-arrows {
  display: grid;
}

.turn-message {
  min-height: 45px;
  margin: 0 0 18px;
  color: #314b5c;
  font-weight: 700;
}

.roll-btn {
  min-width: 170px;
  min-height: 54px;
  font-size: 18px;
}

.question-area {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  margin-top: 14px;
  padding-top: 18px;
  border-top: 2px dashed rgba(21, 83, 113, 0.18);
}

.turn-panel.question-mode .question-area {
  min-height: 0;
  grid-row: 3;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  gap: 7px;
  margin-top: 4px;
  padding-top: 6px;
}

.turn-panel.question-mode .question-area.answer-mode {
  grid-template-rows: minmax(0, 1fr) auto;
}

.question-area.answer-mode .question-topline,
.question-area.answer-mode .question-timer-track,
.question-area.answer-mode .question-action-row {
  display: none;
}

.question-area.hidden {
  display: none;
}

/* Konu + başlık solda, sırası gelen oyuncu ortada, sayaç sağda. */
.question-topline {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
}

.question-heading {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  text-align: left;
}

.question-topline .question-tag {
  flex: none;
  justify-self: start;
  padding: 0.4em 0.95em;
  font-size: clamp(14px, 1.15vw, 26px);
}

.question-title {
  max-width: min(840px, 72vw);
  margin: 0;
  overflow: hidden;
  color: #173d51;
  font-size: clamp(17px, 1.6vw, 34px);
  line-height: 1.22;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.question-timer {
  display: flex;
  align-items: baseline;
  justify-content: center;
  justify-self: end;
  gap: clamp(5px, 0.4vw, 10px);
  min-width: clamp(100px, 9vw, 210px);
  border-radius: clamp(15px, 1vw, 24px);
  padding: clamp(7px, 0.45vw, 12px) clamp(11px, 1vw, 24px);
  background: #173d51;
  color: white;
  box-shadow: 0 7px 18px rgba(18, 61, 81, 0.25);
}

.question-timer span {
  min-width: 1.25em;
  font-size: clamp(24px, 2.5vw, 56px);
  font-weight: 1000;
  line-height: 1;
}

.question-timer small {
  font-size: clamp(11px, 1vw, 22px);
  font-weight: 800;
  opacity: 0.85;
}

.question-timer.is-urgent {
  background: #c43e2e;
  animation: timerPulse 0.8s ease-in-out infinite alternate;
}

/* Son 10 saniyeyi yalnız sayaç rozeti değil, soru çerçevesi ve süre çubuğu da duyurur. */
.question-area:has(.question-timer.is-urgent) .question-media-shell {
  border-color: #d63a26;
  animation: urgentFrame 0.8s ease-in-out infinite alternate;
}

.question-area:has(.question-timer.is-urgent) .question-timer-track {
  background: rgba(196, 62, 46, 0.22);
}

.question-area:has(.question-timer.is-urgent) .question-timer-track span {
  background: linear-gradient(90deg, #ff8a3d, #d63a26);
}

/* Hareket azaltılmışsa çerçeve yanıp sönmez, kalın kırmızı olarak sabit durur. */
@media (prefers-reduced-motion: reduce) {
  .question-area:has(.question-timer.is-urgent) .question-media-shell {
    animation: none;
    box-shadow: 0 0 0 6px rgba(214, 58, 38, 0.95);
  }
}

.question-timer.is-finished {
  background: #687987;
}

.question-media-shell {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  justify-self: center;
  width: 100%;
  height: 100%;
  max-width: 100%;
  aspect-ratio: auto;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 2px solid rgba(21, 83, 113, 0.22);
  border-radius: 18px;
  background: #102737;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.question-media-shell > img,
.question-media-shell > canvas {
  width: auto;
  height: auto;
  min-width: 0;
  min-height: 0;
  max-width: 100%;
  max-height: 100%;
  border: 0;
  object-fit: contain;
  background: white;
}

@media (max-height: 850px) and (min-width: 761px) {
  .question-media-shell {
    width: auto;
  }
}

.question-media-message {
  max-width: 80%;
  color: #dbeaf1;
  font-weight: 800;
  line-height: 1.5;
}

.question-text-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  align-content: center;
  gap: 16px;
  width: 100%;
  height: 100%;
  padding: 32px;
  background: linear-gradient(145deg, #fffdf7, #f2e4c9);
}

.question-text-card h2 {
  margin: 0;
  max-width: 1450px;
  font-size: clamp(32px, 4.3vw, 74px);
  line-height: 1.25;
}

.answer-reveal-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  align-content: center;
  gap: clamp(18px, 3vh, 32px);
  width: 100%;
  height: 100%;
  padding: clamp(30px, 6vw, 72px);
  background: linear-gradient(145deg, #fff8df, #fffdf6);
  color: #263f4c;
}

.answer-reveal-card .teacher-answer-label {
  font-size: clamp(17px, 2vw, 24px);
  letter-spacing: 0.8px;
}

.answer-reveal-card p {
  max-width: 1500px;
  margin: 0;
  font-size: clamp(38px, 5vw, 84px);
  font-weight: 900;
  line-height: 1.3;
  text-align: center;
  white-space: pre-line;
}

.answer-reveal-card.has-media {
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  padding: 16px;
  overflow: hidden;
}

.answer-reveal-card.has-media .teacher-answer-label {
  align-self: start;
}

.answer-reveal-card > canvas,
.answer-reveal-card > img {
  align-self: center;
  justify-self: center;
  min-width: 0;
  min-height: 0;
  max-width: 100%;
  max-height: 100%;
  border: 0;
  background: white;
  box-shadow: 0 8px 28px rgba(12, 40, 54, 0.18);
}

.answer-media-message {
  color: #37586a;
  font-size: 15px;
  font-weight: 900;
  text-align: center;
}

.question-timer-track {
  height: clamp(6px, 0.4vw, 10px);
  overflow: hidden;
  border-radius: 999px;
  background: rgba(23, 61, 81, 0.14);
}

.question-timer-track span {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #32c47d, #19a1d7);
  transition: width 0.2s linear;
}

.question-action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.question-wait-message {
  flex: 1;
  margin: 0;
  color: #2e5367;
  font-size: clamp(13px, 1.05vw, 24px);
  font-weight: 800;
  line-height: 1.3;
  text-align: left;
}

.answer-now-btn {
  flex: 0 0 auto;
  min-width: clamp(150px, 12vw, 280px);
  min-height: clamp(52px, 2.8vw, 66px);
  padding: 8px 24px;
  border-radius: 14px;
  font-size: clamp(17px, 1.35vw, 30px);
}

.teacher-answer-panel {
  display: block;
}

.teacher-answer-label {
  color: #9a6510;
  font-size: 12px;
  font-weight: 1000;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.teacher-decision-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.teacher-correct-btn,
.teacher-wrong-btn {
  border: 0;
  border-radius: 16px;
  min-height: 62px;
  padding: 17px 22px;
  color: white;
  font-size: clamp(18px, 1.6vw, 26px);
  font-weight: 1000;
  cursor: pointer;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.16);
}

.teacher-correct-btn {
  background: linear-gradient(135deg, #23a965, #42ca83);
}

.teacher-wrong-btn {
  background: linear-gradient(135deg, #c73f42, #ef6b55);
}

.teacher-correct-btn:disabled,
.teacher-wrong-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.question-tag,
.modal-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  justify-self: center;
  border-radius: 999px;
  background: linear-gradient(180deg, #21a6dc, #0876ae);
  color: white;
  padding: 7px 16px;
  font-weight: 900;
  font-size: 14px;
  box-shadow: 0 8px 18px rgba(8, 118, 174, 0.22);
}

.feedback {
  padding: 12px 14px;
  border-radius: 14px;
  line-height: 1.45;
  background: #fff4d8;
  color: #7a4f00;
  font-weight: 700;
}

.feedback.good {
  background: #dcf8e5;
  color: #176333;
}

.feedback.bad {
  background: #ffe4e4;
  color: #7b1d1d;
}


.modal.chance-picker .event-card::before,
.modal.chance-picker .event-card::after {
  content: "?";
  position: absolute;
  left: 50%;
  top: 108px;
  width: 76px;
  height: 102px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: linear-gradient(145deg, #fff4c7, #f7b842);
  color: #155277;
  font-size: 42px;
  font-weight: 1000;
  box-shadow: 0 15px 25px rgba(0, 0, 0, 0.24);
  transform-origin: center bottom;
  animation: cardShuffleA 0.82s ease-in-out infinite;
}

.modal.chance-picker .event-card::after {
  animation-name: cardShuffleB;
  background: linear-gradient(145deg, #dbfff0, #39c97c);
}

.modal.chance-picker .event-card {
  position: relative;
  min-height: 335px;
  padding-top: 34px;
  overflow: hidden;
}

.modal.chance-picker #info-title {
  margin-top: 138px;
}

.modal.chance-modal .event-card {
  width: min(760px, 100%);
  border-color: rgba(247, 193, 43, 0.92);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.32), 0 0 0 7px rgba(247, 193, 43, 0.17);
}

.modal.chance-modal #info-title {
  font-size: clamp(28px, 4vw, 46px);
}

.modal.chance-modal #info-text {
  font-size: clamp(20px, 2.3vw, 30px);
  font-weight: 800;
  line-height: 1.4;
}

.modal.acid-modal .event-card {
  border-color: rgba(139, 230, 57, 0.92);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.32), 0 0 0 7px rgba(139, 230, 57, 0.18);
}

.modal.wrong-modal .event-card {
  border-color: rgba(230, 70, 70, 0.72);
}

/* Adaya varış kartı: üstte logo, altında iple asılı ahşap "Tebrikler" tabelası. */
.modal.island-modal .event-card {
  border-color: rgba(45, 190, 118, 0.92);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.32), 0 0 0 7px rgba(45, 190, 118, 0.18);
}

.modal.island-modal .event-card::before {
  content: "";
  display: block;
  height: 96px;
  margin-bottom: 10px;
  background: url("../assets/kimya-adasi-logo.png?v=2") center / contain no-repeat;
}

.modal.island-modal .info-image {
  width: min(400px, 92%);
  height: auto;
  object-fit: contain;
  margin: 2px auto 0;
  border-radius: 0;
}

.modal-card {
  text-align: center;
  transform: translateY(-12px);
}

.event-card {
  border: 3px solid rgba(255, 255, 255, 0.75);
}

.modal-actions {
  display: flex;
  justify-content: center;
  margin-top: 20px;
}

.winner-card {
  width: min(650px, 100%);
  /* Çok kazananda ya da kalabalık sıralamada içerik sığmazsa kart kayar; üstteki logo kesilmez. */
  overflow: hidden auto;
  overscroll-behavior: contain;
  padding: 36px 34px 34px;
  text-align: center;
  /* Süs halkaları arka plan katmanıdır: taşan öğe olmadıkları için kaydırma alanını uzatmazlar. */
  background:
    radial-gradient(circle at calc(100% + 2px) -5px, transparent 47.5px, rgba(50, 196, 125, 0.08) 48px 70px, transparent 70.5px),
    radial-gradient(circle at -15px calc(100% + 15px), rgba(20, 151, 209, 0.07) 95px, transparent 95.5px),
    radial-gradient(circle at 12% 18%, rgba(20, 151, 209, 0.12) 0 5px, transparent 6px),
    radial-gradient(circle at 87% 25%, rgba(50, 196, 125, 0.14) 0 7px, transparent 8px),
    linear-gradient(160deg, rgba(255, 255, 255, 0.98), rgba(248, 241, 222, 0.98));
}

.winner-badge {
  position: relative;
  width: 150px;
  height: 150px;
  margin: 0 auto 18px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(54, 167, 219, 0.2);
  border-radius: 45px;
  background: linear-gradient(160deg, #e9fae5, #fff2c3);
  box-shadow: inset 0 0 0 7px rgba(255, 255, 255, 0.52), 0 16px 34px rgba(18, 132, 162, 0.17);
}

.winner-badge::before,
.winner-badge::after {
  content: "✦";
  position: absolute;
  color: #e8a238;
  font-size: 20px;
}

.winner-badge::before {
  left: -28px;
  top: 20px;
}

.winner-badge::after {
  right: -25px;
  bottom: 23px;
  color: #32b875;
  font-size: 16px;
}

.winner-tree-crop {
  position: relative;
  width: 126px;
  height: 126px;
  overflow: hidden;
  border-radius: 37px;
}

.winner-tree-crop img {
  position: absolute;
  top: -4px;
  left: -3px;
  width: 310px;
  max-width: none;
  height: 155px;
  object-fit: contain;
}

.winner-card h1 {
  margin-bottom: 10px;
  font-size: clamp(38px, 7vw, 62px);
  line-height: 1.08;
}

.winner-card p {
  margin: 0 auto 24px;
  max-width: 520px;
  font-size: 18px;
}

.winner-card #restart-btn {
  min-width: 245px;
  font-size: 17px;
}

/* Kısa ekranda (1366×768 ve altı) logo, başlık ve sıralama kaydırmadan sığsın. */
@media (max-height: 820px) {
  .winner-card {
    padding: 22px 28px 24px;
  }

  .winner-badge {
    width: 96px;
    height: 96px;
    margin-bottom: 10px;
    border-radius: 30px;
  }

  .winner-tree-crop {
    width: 80px;
    height: 80px;
    border-radius: 24px;
  }

  .winner-tree-crop img {
    top: -3px;
    left: -2px;
    width: 197px;
    height: 98px;
  }

  .winner-card h1 {
    margin-bottom: 6px;
    font-size: clamp(30px, 5vw, 44px);
  }

  .winner-card p {
    margin-bottom: 14px;
    font-size: 16px;
  }

  .winner-ranking {
    gap: 4px;
    margin-bottom: 16px;
  }

  .winner-ranking li {
    padding: 6px 12px;
  }
}

.turn-panel.compact .dice-box,
.turn-panel.compact .roll-btn,
.turn-panel.compact .question-area {
  display: none;
}

.turn-panel.compact .turn-body {
  padding: 16px 18px;
}

.turn-panel.compact .turn-header {
  min-height: 42px;
  font-size: 22px;
}

.turn-panel.compact .turn-player {
  margin-bottom: 8px;
}

.turn-panel.compact .turn-message {
  min-height: auto;
  margin-bottom: 0;
}

/* Akıllı tahta ve geniş ekranlarda oyun arayüzünü uzaktan okunur tut. */
@media (min-width: 1000px) {
  .continue-panel {
    bottom: clamp(28px, 2.2vw, 44px);
  }

  .continue-panel .primary-btn {
    padding: clamp(13px, 1vw, 18px) clamp(24px, 1.8vw, 32px);
    font-size: clamp(18px, 1.25vw, 24px);
  }

  /* Zar paneli: sıra, mesaj ve "Zar At" arka sıradan okunur. */
  .turn-panel:not(.compact):not(.question-mode) {
    width: clamp(440px, 30vw, 680px);
  }

  .turn-panel:not(.compact):not(.question-mode) .turn-header {
    min-height: clamp(55px, 3.8vw, 86px);
    font-size: clamp(32px, 2.2vw, 48px);
  }

  .turn-panel:not(.compact):not(.question-mode) .turn-player {
    min-height: clamp(32px, 2.6vw, 58px);
    padding: 6px clamp(13px, 1.2vw, 26px);
    font-size: clamp(22px, 1.6vw, 36px);
  }

  .turn-panel:not(.compact):not(.question-mode) .dice-box {
    min-height: clamp(142px, 9.8vw, 216px);
  }

  .turn-panel:not(.compact):not(.question-mode) .dice-face {
    width: clamp(92px, 6.4vw, 140px);
    height: clamp(92px, 6.4vw, 140px);
    gap: clamp(9px, 0.63vw, 14px);
    padding: clamp(13px, 0.9vw, 20px);
    border-radius: clamp(20px, 1.4vw, 30px);
  }

  .turn-panel:not(.compact):not(.question-mode) .dice-arrows {
    font-size: clamp(122px, 8.5vw, 186px);
  }

  .turn-panel:not(.compact):not(.question-mode) .turn-message {
    font-size: clamp(17px, 1.35vw, 30px);
    line-height: 1.35;
  }

  .roll-btn {
    min-width: clamp(170px, 12vw, 280px);
    min-height: clamp(54px, 3.3vw, 76px);
    font-size: clamp(18px, 1.4vw, 30px);
  }

  .turn-panel.compact {
    top: calc(100% - clamp(28px, 2.2vw, 44px));
    width: min(600px, calc(100% - 40px));
  }

  .turn-panel.compact .turn-header {
    min-height: clamp(62px, 4.8vw, 86px);
    font-size: clamp(30px, 2.3vw, 42px);
    border-radius: 26px 26px 14px 14px;
  }

  .turn-panel.compact .turn-body {
    padding: clamp(24px, 2vw, 36px) clamp(28px, 2.4vw, 44px);
    border-radius: clamp(30px, 2.5vw, 44px);
  }

  .turn-panel.compact .turn-player {
    min-height: clamp(42px, 3.4vw, 58px);
    margin-bottom: clamp(14px, 1.2vw, 22px);
    padding: 8px clamp(18px, 1.5vw, 28px);
    font-size: clamp(19px, 1.45vw, 27px);
  }

  .turn-panel.compact .turn-message {
    font-size: clamp(20px, 1.55vw, 29px);
    line-height: 1.35;
  }
}


@keyframes turnBadgePulse {
  0% {
    box-shadow: 0 0 0 0 var(--turn-color), 0 12px 26px rgba(0, 0, 0, 0.22);
  }

  100% {
    box-shadow: 0 0 0 22px transparent, 0 12px 26px rgba(0, 0, 0, 0.22);
  }
}

@keyframes confettiFall {
  0% {
    opacity: 1;
    transform: translate3d(0, 0, 0) rotate(0deg);
  }

  85% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    transform: translate3d(var(--drift, 0px), 108vh, 0) rotate(var(--spin, 540deg));
    /* Kap yüksekliği: büyütülmüş arayüzde (bkz. .ui-scaled) vh iki kat sayılmasın. */
    transform: translate3d(var(--drift, 0px), 108cqh, 0) rotate(var(--spin, 540deg));
  }
}

@keyframes winnerPop {
  0% {
    opacity: 0;
    transform: scale(0.82) translateY(24px);
  }

  100% {
    opacity: 1;
    transform: none;
  }
}

@keyframes winnerBadgeFloat {
  0% {
    transform: translateY(0) rotate(-2deg);
  }

  100% {
    transform: translateY(-8px) rotate(2deg);
  }
}

@keyframes cardShuffleA {
  0% {
    transform: translateX(-84px) rotate(-15deg) translateY(0);
  }

  50% {
    transform: translateX(-38px) rotate(8deg) translateY(-10px);
  }

  100% {
    transform: translateX(-84px) rotate(-15deg) translateY(0);
  }
}

@keyframes cardShuffleB {
  0% {
    transform: translateX(6px) rotate(13deg) translateY(-4px);
  }

  50% {
    transform: translateX(-32px) rotate(-8deg) translateY(11px);
  }

  100% {
    transform: translateX(6px) rotate(13deg) translateY(-4px);
  }
}

@keyframes diceSpin {
  0% {
    transform: rotate(-12deg) scale(1);
  }

  35% {
    transform: rotate(55deg) scale(1.08);
  }

  70% {
    transform: rotate(160deg) scale(0.98);
  }

  100% {
    transform: rotate(348deg) scale(1);
  }
}

@keyframes arrowTurn {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

@keyframes timerPulse {
  from {
    transform: scale(1);
  }

  to {
    transform: scale(1.04);
  }
}

@keyframes urgentFrame {
  from {
    box-shadow: 0 0 0 2px rgba(214, 58, 38, 0.35);
  }

  to {
    box-shadow: 0 0 0 6px rgba(214, 58, 38, 0.95);
  }
}

@media (max-width: 760px) {
  .admin-modal {
    padding: 0;
  }

  .admin-card {
    width: 100%;
    height: 100%;
    border-radius: 0;
  }

  .admin-header {
    padding: 14px 16px 12px;
  }

  .admin-header p {
    display: none;
  }

  .admin-toolbar {
    grid-template-columns: 0.65fr 1.35fr;
    padding: 10px 14px;
  }

  .admin-toolbar label:last-child {
    grid-column: 1 / -1;
  }

  .admin-workspace {
    grid-template-columns: 1fr;
    overflow-y: auto;
  }

  .admin-list-panel {
    min-height: 370px;
    max-height: 48vh;
    border-right: 0;
    border-bottom: 1px solid #d6e7ef;
  }

  .admin-editor-panel {
    overflow: visible;
  }

  .admin-media-row {
    grid-template-columns: 1fr;
  }

  .admin-media-preview {
    height: 180px;
    min-height: 0;
  }

  .admin-footer {
    padding: 9px 14px;
  }

  .admin-footer span {
    display: none;
  }

  .admin-footer .plain-btn {
    width: 100%;
  }

  .setup-grid {
    grid-template-columns: 1fr;
  }

  #start-screen .wide-card[data-setup-step="players"] {
    padding: 18px;
  }

  #start-screen .wide-card[data-setup-step="players"] .brand-block {
    grid-template-columns: 1fr auto;
  }

  #start-screen .wide-card[data-setup-step="players"] .brand-logo {
    max-width: 145px;
    max-height: 52px;
  }

  .players-setup-grid {
    grid-template-columns: 1fr;
  }

  .players-setup-grid .name-fields {
    grid-template-columns: 1fr;
  }

  .brand-logo {
    max-width: 220px;
    max-height: 72px;
  }


  .grade-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hud-badges {
    right: 10px;
    top: auto;
    bottom: 82px;
  }

  .round-badge,
  .topic-badge {
    padding: 9px 12px;
    min-width: 86px;
    font-size: 12px;
  }

  .topic-badge {
    max-width: 46vw;
  }


  .game-logo {
    left: 68px;
    top: 10px;
    min-height: 46px;
  }

  .menu-btn {
    left: 10px;
    top: 10px;
  }

  .turn-panel.question-mode ~ .menu-btn {
    left: 12px;
  }

  .turn-badge {
    left: 10px;
    top: 64px;
    transform: none;
    min-height: 40px;
    max-width: calc(100vw - 20px);
    border-width: 3px;
  }

  .turn-badge small {
    display: inline;
  }

  .game-logo-img {
    height: 46px;
  }

  .icon-btn {
    width: 46px;
    height: 46px;
    font-size: 24px;
  }

  .youtube-play-mark {
    width: 31px;
    height: 22px;
  }

  .continue-panel {
    bottom: 12px;
  }

  .turn-panel {
    width: min(390px, calc(100% - 24px));
  }

  .turn-panel.question-mode {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-height: none;
  }

  .turn-panel.question-mode .turn-header {
    width: auto;
    margin: 0 14px -2px 58px;
    min-height: 42px;
    font-size: 17px;
  }

  .turn-panel.question-mode .turn-body {
    max-height: calc(100vh - 48px);
    padding: 10px;
  }

  .turn-panel.question-mode .turn-message {
    display: none;
  }

  .question-media-shell {
    width: 100%;
    height: 100%;
    max-width: 100%;
    aspect-ratio: auto;
    min-height: 0;
    border-radius: 13px;
  }

  .question-topline {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: stretch;
    gap: 6px 12px;
  }

  /* Dar ekranda oyuncu satırı başlık ve sayacın üstünde, kendi satırında durur. */
  .turn-panel.question-mode .turn-player.question-player {
    grid-column: 1 / -1;
    order: -1;
  }

  .question-topline .question-tag {
    flex: 0 1 auto;
    justify-content: flex-start;
    max-width: calc(100vw - 125px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .question-title {
    max-width: calc(100vw - 125px);
    font-size: 16px;
  }

  .question-timer {
    min-width: 90px;
  }

  .question-text-card {
    padding: 20px;
  }

  .answer-reveal-card {
    gap: 14px;
    padding: 24px 18px;
  }

  .answer-reveal-card p {
    font-size: clamp(23px, 7vw, 36px);
  }

  .question-action-row {
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
  }

  .question-wait-message {
    text-align: center;
  }

  .teacher-decision-actions {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .teacher-correct-btn,
  .teacher-wrong-btn {
    padding: 13px;
  }

  .turn-panel.compact {
    top: auto;
    bottom: 14px;
    transform: translateX(-50%);
  }
}

/* Dik telefonda zar paneli alta yanaşınca sağ alttaki rozetleri örter: tur rozeti
   logonun sağına çıkar, konu rozeti panel kapanana dek gizlenir. */
@media (max-width: 760px) and (orientation: portrait) {
  body:has(.turn-panel:not(.hidden):not(.compact):not(.question-mode)) .hud-badges {
    top: 16px;
    bottom: auto;
  }

  body:has(.turn-panel:not(.hidden):not(.compact):not(.question-mode)) .topic-badge {
    display: none;
  }
}

/* Büyük ekran ölçeği (js/ui-scale.js): 1920×1080'den büyük görünümlerde arayüz katmanları
   ekranla orantılı büyür, sahne tuvali olduğu gibi kalır. Büyütülen öğenin içinde vw/vh
   tarayıcıya göre farklı çözülür; yerleşimi belirleyen ölçüler bu yüzden yüzdeyle verilir. */
:root.ui-scaled body > :not(#scene-root) {
  zoom: var(--ui-scale);
}

:root.ui-scaled .panel-card,
:root.ui-scaled .modal-card,
:root.ui-scaled #start-screen .wide-card[data-setup-step="players"] {
  max-height: 100%;
}

:root.ui-scaled #start-screen .wide-card[data-setup-step="units"] {
  height: 100%;
  max-height: 100%;
}

:root.ui-scaled .admin-card {
  height: min(820px, 100%);
}

:root.ui-scaled .turn-badge {
  max-width: calc(100% - 552px);
}

:root.ui-scaled .turn-panel.question-mode {
  width: auto;
  height: auto;
}

/* Açılış ekranındaki üç düğme: Soru Yönetimi, Kendi Sorularım, Şifre ile Oyna. */
.start-tools {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 4px;
}

.start-tools .admin-entry-btn {
  margin-top: 12px;
}

/* Kendi Sorularım (soru seti) ve Şifre ile Oyna pencereleri. */
.custom-set-modal,
.custom-play-modal {
  z-index: 90;
  padding: 16px;
}

.custom-set-card {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(1180px, 100%);
  height: min(820px, calc(100vh - 32px));
  overflow: hidden;
  border-radius: 26px;
  border: 1px solid rgba(255, 255, 255, 0.82);
  background: #f5f9fb;
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.38);
}

.custom-set-build {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  min-height: 0;
}

.custom-set-workspace {
  display: grid;
  grid-template-columns: minmax(330px, 0.9fr) minmax(390px, 1.1fr);
  min-height: 0;
}

.custom-set-unit-label {
  display: grid;
  gap: 6px;
  color: #173d51;
  font-size: 13px;
  font-weight: 900;
}

.custom-set-unit-label select {
  width: 100%;
  min-height: 42px;
  border: 1px solid #c5dbe5;
  border-radius: 13px;
  padding: 0 12px;
  background: #fff;
  color: #173d51;
  font: inherit;
  font-weight: 700;
}

.custom-set-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border: 1px solid #d3e2e9;
  border-radius: 15px;
  background: #fff;
}

.custom-set-row.is-picked {
  border-color: #20a3d2;
  background: #f2fbff;
}

.custom-set-name {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  padding: 4px 2px;
  border: 0;
  background: none;
  color: #244558;
  font: inherit;
  font-weight: 800;
  text-align: left;
  cursor: pointer;
}

.custom-set-name small {
  color: #167444;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.custom-set-action {
  min-height: 38px;
  padding: 8px 14px;
  border-radius: 12px;
  font-size: 13px;
}

.custom-set-side {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 12px;
  min-height: 0;
  padding: 18px 20px;
}

.custom-set-preview {
  display: grid;
  gap: 8px;
  justify-items: start;
}

.custom-set-preview-title {
  margin: 0;
  color: #173d51;
  font-size: 14px;
  font-weight: 800;
}

.custom-set-preview-frame {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 150px;
  max-height: 260px;
  overflow: hidden;
  border: 1px dashed #c5dbe5;
  border-radius: 14px;
  background: #fff;
}

.custom-set-preview-frame img {
  max-width: 100%;
  max-height: 252px;
  object-fit: contain;
}

.custom-set-chosen-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  color: #173d51;
  font-size: 14px;
}

.custom-set-chosen-head span {
  color: #638092;
  font-size: 13px;
  font-weight: 800;
}

.custom-set-chosen {
  display: grid;
  align-content: start;
  gap: 7px;
  min-height: 0;
  margin: 0;
  padding: 0 4px 0 0;
  overflow-y: auto;
  counter-reset: pick;
  list-style: none;
}

.custom-set-chosen li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border: 1px solid #d3e2e9;
  border-radius: 12px;
  background: #fff;
  color: #244558;
  font-size: 13px;
  font-weight: 700;
}

.custom-set-chosen li:not(.custom-set-empty)::before {
  counter-increment: pick;
  content: counter(pick) ".";
  color: #125277;
  font-weight: 900;
}

.custom-set-chosen li > span {
  flex: 1;
  min-width: 0;
}

.custom-set-empty {
  justify-content: center;
  border-style: dashed;
  color: #638092;
}

.custom-set-remove {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: #eef5f8;
  color: #b52e35;
  font-weight: 900;
  cursor: pointer;
}

.custom-set-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 20px;
  border-top: 1px solid #d6e7ef;
  background: #fff;
}

.custom-set-footer .admin-status {
  flex: 1;
  min-width: 0;
}

.custom-set-footer-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.custom-set-result {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 16px;
  padding: 36px 28px;
  text-align: center;
  color: #173d51;
}

.custom-set-result h2 {
  margin: 0;
  font-size: 28px;
}

.custom-set-result p {
  max-width: 620px;
  margin: 0;
  color: #577180;
  font-weight: 700;
  line-height: 1.5;
}

.custom-set-password {
  display: block;
  padding: 18px 24px;
  border: 2px dashed #20a3d2;
  border-radius: 18px;
  background: #fff;
  color: #125277;
  font-family: ui-monospace, Menlo, monospace;
  font-size: clamp(20px, 3vw, 30px);
  font-weight: 900;
  letter-spacing: 0.06em;
  user-select: all;
  overflow-wrap: anywhere;
}

.custom-play-card {
  display: grid;
  gap: 12px;
  width: min(520px, 100%);
  padding: 28px;
  border-radius: 24px;
  background: #f5f9fb;
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.38);
}

.custom-play-card h1 {
  margin: 0;
  color: #173d51;
  font-size: 26px;
}

.custom-play-card p {
  margin: 0;
  color: #577180;
  font-weight: 700;
}

.custom-play-card input {
  width: 100%;
  min-height: 56px;
  padding: 0 16px;
  border: 1px solid #c5dbe5;
  border-radius: 14px;
  background: #fff;
  color: #173d51;
  font: inherit;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.custom-play-card input:focus {
  outline: 3px solid rgba(32, 163, 210, 0.3);
  border-color: #20a3d2;
}

/* Kendi Sorularım: sol sütunda hazır soru listesi ile kendi soru formu yer değiştirir. */
.custom-set-left {
  grid-template-rows: minmax(0, 1fr);
}

.custom-set-browse {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: 0;
}

.custom-set-browse .admin-list-heading {
  margin-bottom: 12px;
}

.custom-own-new-btn {
  display: grid;
  gap: 3px;
  margin-top: 12px;
  padding: 13px 16px;
  border: 2px dashed #20a3d2;
  border-radius: 16px;
  background: #fff;
  color: #0d729c;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.custom-own-new-btn b {
  font-size: 16px;
}

.custom-own-new-btn small {
  color: #577180;
  font-size: 12px;
  font-weight: 700;
}

.custom-own-new-btn:hover {
  background: #f2fbff;
}

.custom-own-form {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 0;
  margin: -18px -20px;
  padding: 18px 20px;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: #fff;
}

.custom-own-form .admin-editor-heading {
  margin-bottom: 2px;
}

.custom-own-form .admin-editor-heading h2 {
  margin: 3px 0 0;
  font-size: 22px;
}

.custom-own-form .danger-btn {
  min-height: 40px;
  padding: 8px 13px;
  border: 1px solid #efb4b7;
  border-radius: 12px;
  background: #fff;
  font-weight: 900;
  cursor: pointer;
}

.custom-own-form textarea {
  padding: 11px 12px;
  border-radius: 13px;
}

.custom-own-photo {
  display: grid;
  grid-template-columns: minmax(150px, 0.8fr) minmax(180px, 1.2fr);
  align-items: start;
  gap: 10px;
}

.custom-own-photo .admin-file-field {
  font-size: 12px;
}

.custom-own-photo .admin-media-preview {
  height: 150px;
}

.custom-own-form .custom-set-footer-actions {
  margin-top: 4px;
}

.custom-set-row.is-previewed {
  box-shadow: 0 0 0 3px rgba(32, 163, 210, 0.18);
}

.custom-set-name-text {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.custom-set-name-text em {
  overflow: hidden;
  color: #6c8492;
  font-size: 12px;
  font-style: normal;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.custom-set-preview-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.custom-set-preview-actions .plain-btn {
  min-height: 40px;
  padding: 8px 14px;
  border-radius: 12px;
}

.custom-set-preview-text {
  max-height: 240px;
  margin: 0;
  padding: 16px 20px;
  overflow-y: auto;
  color: #173d51;
  font-size: 18px;
  font-weight: 800;
  line-height: 1.45;
  text-align: center;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.custom-set-chosen li.is-previewed {
  border-color: #20a3d2;
  background: #f2fbff;
}

.custom-set-chosen-open {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 2px 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.custom-set-chosen-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.custom-set-source {
  flex: 0 0 auto;
  padding: 3px 8px;
  border-radius: 999px;
  background: #e3f5fc;
  color: #0d7aa8;
  font-size: 11px;
  font-weight: 900;
}

.custom-set-source.is-own {
  background: #e6f7ec;
  color: #167444;
}

@media (max-width: 980px) {
  .custom-set-workspace {
    grid-template-columns: minmax(0, 1fr);
    overflow-y: auto;
  }

  .custom-set-build {
    overflow-y: auto;
  }
}
