:root {
  color-scheme: dark;
  --ink: #f8f4ff;
  --muted: #cabee1;
  --bg: #120f1f;
  --purple: #6d2ee8;
  --purple-deep: #401295;
  --green: #bdf95b;
  --coral: #ff7a59;
  --cyan: #72e4ff;
  --card: rgba(255, 255, 255, 0.1);
  --line: rgba(255, 255, 255, 0.18);
  --shadow: 0 24px 60px rgba(21, 8, 48, 0.42);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 20% 0%, rgba(189, 249, 91, 0.18), transparent 26rem),
    radial-gradient(circle at 85% 20%, rgba(255, 122, 89, 0.16), transparent 24rem),
    linear-gradient(145deg, #1a102f 0%, #16112b 46%, #0d1020 100%);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(100%, 520px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px;
}

.hero-panel {
  position: relative;
  overflow: hidden;
  min-height: 520px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background:
    linear-gradient(160deg, rgba(109, 46, 232, 0.98), rgba(64, 18, 149, 0.92) 55%, rgba(18, 15, 31, 0.94)),
    url("data:image/svg+xml,%3Csvg width='240' height='240' viewBox='0 0 240 240' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='rgba(255,255,255,.14)' stroke-width='1'%3E%3Cpath d='M20 120h200M120 20v200M46 46l148 148M194 46 46 194'/%3E%3Ccircle cx='120' cy='120' r='78'/%3E%3Ccircle cx='120' cy='120' r='22'/%3E%3C/g%3E%3C/svg%3E");
  box-shadow: var(--shadow);
}

.hero-panel::after {
  position: absolute;
  right: -56px;
  bottom: 135px;
  width: 190px;
  height: 190px;
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  content: "";
}

.topbar,
.ticket-header,
.ticket-footer,
.panel-heading,
.input-row,
.action-grid {
  display: flex;
  align-items: center;
}

.topbar,
.panel-heading,
.ticket-header,
.ticket-footer {
  justify-content: space-between;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 16px;
  background: var(--green);
  color: #1a102f;
  font-weight: 800;
}

.round-status,
.ticket-chip {
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  padding: 9px 13px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 700;
}

.hero-copy {
  position: relative;
  z-index: 1;
  margin-top: 86px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--green);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 12px;
  font-size: clamp(4.3rem, 18vw, 6.4rem);
  line-height: 0.9;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

body.has-player h1 {
  font-size: clamp(2.8rem, 13vw, 5rem);
  line-height: 0.95;
}

body.has-player .hero-panel {
  min-height: auto;
}

body.has-player .hero-copy {
  margin-top: 72px;
}

.subtitle {
  max-width: 19rem;
  margin-bottom: 0;
  color: rgba(248, 244, 255, 0.82);
  font-size: 1.04rem;
  line-height: 1.5;
}

.entry-card {
  position: relative;
  z-index: 1;
  margin-top: 28px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(18, 15, 31, 0.74);
  backdrop-filter: blur(18px);
}

.draw-card {
  position: absolute;
  right: 16px;
  bottom: 16px;
  left: 16px;
  z-index: 1;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(18, 15, 31, 0.74);
  backdrop-filter: blur(18px);
  display: none;
}

body.has-player .entry-card {
  display: none;
}

body.has-player .draw-card {
  display: block;
  position: relative;
  inset: auto;
  margin-top: 24px;
}

body.is-admin .admin-intro {
  display: block;
}

body.is-admin .entry-card label[for="entryName"],
body.is-admin .field-stack,
body.is-admin .entry-card .full-btn,
body.is-admin.has-player .draw-card {
  display: none;
}

body.is-admin.has-player .entry-card {
  display: none;
}

body.is-admin .pool-option {
  min-height: 76px;
  text-align: left;
}

.admin-intro {
  display: none;
}

.admin-intro p {
  margin: 0 0 14px;
  color: rgba(248, 244, 255, 0.72);
  font-size: 0.9rem;
  line-height: 1.4;
}

.create-pool-panel {
  display: none;
  margin: 12px 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.08);
}

.create-pool-panel.is-visible,
body.is-admin .create-pool-panel {
  display: block;
}

.create-pool-copy p {
  margin: 0 0 12px;
  color: rgba(248, 244, 255, 0.72);
  font-size: 0.84rem;
  line-height: 1.4;
}

body.is-admin .create-toggle {
  display: none;
}

.admin-create {
  display: flex;
  gap: 8px;
}

.admin-create input {
  height: 46px;
}

.admin-create button {
  flex: 0 0 auto;
}

label {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

fieldset {
  min-width: 0;
  margin: 12px 0 0;
  border: 0;
  padding: 0;
}

legend {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.pool-help {
  margin: -2px 0 12px;
  color: rgba(248, 244, 255, 0.72);
  font-size: 0.82rem;
  line-height: 1.4;
}

.draw-card-header {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.draw-card-header label {
  margin-bottom: 0;
}

.draw-card-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
  margin-left: auto;
}

.field-stack {
  display: grid;
  gap: 10px;
}

.player-suggestions {
  display: none;
  gap: 8px;
  margin-top: 10px;
}

.player-suggestions.has-results {
  display: grid;
}

.suggestion-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  text-align: left;
}

.suggestion-btn strong,
.suggestion-btn span {
  display: block;
}

.suggestion-btn strong {
  font-size: 0.9rem;
}

.suggestion-btn span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.76rem;
}

.suggestion-team {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 7px 9px;
  background: var(--green);
  color: #151022;
  font-size: 0.72rem;
  font-weight: 800;
}

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

.pool-option {
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 800;
}

.pool-option.is-selected {
  border-color: var(--green);
  background: var(--green);
  color: #151022;
}

.input-row {
  gap: 10px;
}

input {
  min-width: 0;
  width: 100%;
  height: 54px;
  border: 1px solid transparent;
  border-radius: 16px;
  outline: none;
  padding: 0 15px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--ink);
  font-size: 1rem;
}

input:focus {
  border-color: var(--green);
}

input::placeholder {
  color: rgba(248, 244, 255, 0.45);
}

.full-btn {
  width: 100%;
  margin-top: 10px;
}

.create-question {
  margin: 12px 0 0;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 800;
}

.create-toggle {
  margin-top: 8px;
}

.link-btn {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--green);
  font-size: 0.84rem;
  font-weight: 800;
}

.outline-green-btn {
  width: auto;
  min-height: 36px;
  border: 1px solid var(--green);
  border-radius: 12px;
  padding: 0 12px;
  background: transparent;
  color: var(--green);
  font-size: 0.76rem;
  font-weight: 800;
  white-space: nowrap;
}

.admin-only {
  display: none;
}

body.is-admin .admin-only {
  display: flex;
}

.admin-actions {
  gap: 8px;
}

.compact-btn {
  min-height: 42px;
  border-radius: 14px;
  padding: 0 12px;
  white-space: nowrap;
}

.danger-btn {
  min-height: 54px;
  border: 0;
  border-radius: 16px;
  padding: 0 18px;
  background: var(--coral);
  color: #1a102f;
  font-weight: 800;
}

.primary-btn,
.secondary-btn,
.ghost-btn {
  min-height: 54px;
  border: 0;
  border-radius: 16px;
  padding: 0 18px;
  font-weight: 800;
}

.primary-btn,
.secondary-btn {
  background: var(--green);
  color: #151022;
}

.primary-btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.form-note {
  margin: 12px 0 0;
  color: rgba(248, 244, 255, 0.68);
  font-size: 0.82rem;
  line-height: 1.4;
}

.result-panel,
.teams-panel {
  margin-top: 16px;
}

.result-panel.is-hidden {
  display: none;
}

.ticket {
  overflow: hidden;
  min-height: 430px;
  padding: 14px;
  border-radius: 18px;
  background:
    linear-gradient(145deg, #f6f1df, #fdfaf0 48%, #ded2b7),
    repeating-linear-gradient(135deg, rgba(64, 18, 149, 0.16), rgba(64, 18, 149, 0.16) 1px, transparent 1px, transparent 13px);
  color: #191526;
  box-shadow: var(--shadow);
}

.ticket::before {
  display: block;
  height: 8px;
  margin: -2px -2px 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--purple), var(--coral), var(--green), var(--cyan));
  content: "";
}

.ticket-kicker,
.ticket-footer {
  color: rgba(25, 21, 38, 0.66);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.ticket-chip {
  border-color: rgba(25, 21, 38, 0.16);
  background: #191526;
  color: #fdfaf0;
}

.sticker-art {
  display: grid;
  min-height: 205px;
  margin: 14px 0 16px;
  place-items: center;
  border: 6px solid #191526;
  border-radius: 12px;
  background:
    radial-gradient(circle at 50% 40%, rgba(255, 255, 255, 0.55), transparent 7rem),
    linear-gradient(150deg, var(--purple) 0%, var(--coral) 52%, #191526 100%);
  box-shadow: inset 0 0 0 4px rgba(255, 255, 255, 0.58);
}

.sticker-art span {
  display: grid;
  width: 118px;
  height: 118px;
  place-items: center;
  border: 5px solid rgba(255, 255, 255, 0.86);
  border-radius: 50%;
  background: var(--green);
  color: #191526;
  font-size: 4.3rem;
  font-weight: 800;
  line-height: 1;
}

.ticket h2 {
  margin: 0 0 7px;
  font-size: clamp(1.55rem, 7vw, 2.5rem);
  line-height: 1;
}

.ticket p {
  margin-bottom: 28px;
  color: var(--purple-deep);
  font-size: clamp(2.1rem, 10vw, 3.4rem);
  font-weight: 800;
  line-height: 0.95;
}

.action-grid {
  gap: 10px;
  margin-top: 12px;
}

.action-grid button {
  flex: 1;
}

.ghost-btn {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
}

.teams-panel {
  padding: 20px 0 26px;
}

body:not(.has-player):not(.is-admin) .teams-panel {
  display: none;
}

.panel-heading h2 {
  margin-bottom: 0;
  font-size: 1.2rem;
}

.pool-summary {
  max-width: 19rem;
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.35;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.stats-grid div {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.08);
}

.stats-grid strong,
.stats-grid span {
  display: block;
}

.stats-grid strong {
  color: var(--green);
  font-size: 1.5rem;
  line-height: 1;
}

.stats-grid span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
}

.history-panel {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.08);
}

.history-panel h3,
.section-title {
  margin: 0 0 10px;
  color: var(--ink);
  font-size: 0.96rem;
}

.section-title {
  margin-top: 18px;
}

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

.history-empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.history-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
  min-height: 46px;
}

.history-number {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 11px;
  background: var(--green);
  color: #151022;
  font-size: 0.78rem;
  font-weight: 800;
}

.history-item strong {
  display: block;
  color: var(--ink);
  font-size: 0.9rem;
}

.history-item span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.78rem;
}

.icon-btn {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
}

.icon-btn svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.teams-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.team-pill {
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.08);
}

.team-pill strong {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: 0.92rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.team-pill span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.74rem;
}

.team-pill.is-taken {
  opacity: 0.46;
}

#shareCanvas {
  display: none;
}

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

  .hero-panel {
    min-height: 500px;
    border-radius: 24px;
  }

  body:not(.has-player) .hero-panel {
    min-height: auto;
  }

  .input-row,
  .action-grid,
  .pool-list {
    align-items: stretch;
    flex-direction: column;
    display: flex;
  }

  .primary-btn {
    width: 100%;
  }
}
