:root {
  --keno-green: #99ff00;
  --keno-green-dim: #5caa00;
  --keno-yellow: #ffe14a;
  --keno-red: #ff3b2f;
  --keno-brown: #6b3d12;
  --keno-brown-hi: #9a5a1c;
  --keno-black: #050805;
  --keno-panel: rgba(0, 0, 0, 0.78);
  --keno-text: #d8ffb0;
}

html.keno-standalone,
html.keno-standalone body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: #020400;
  color: var(--keno-text);
  font-family: Arial, Helvetica, sans-serif;
}

#keno-fallback, noscript p {
  margin: 12px;
  color: var(--keno-green);
  text-align: center;
}

#keno-root {
  display: block;
  width: 100%;
  min-height: 0;
  height: auto;
  position: relative;
  z-index: 1;
  overflow: visible;
  --keno-width: 700px;
}

.keno-app {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  min-height: 0;
  height: auto;
  padding: 8px 10px 12px;
  overflow: visible;
  background:
    linear-gradient(180deg, rgba(0, 20, 0, 0.28), rgba(0, 0, 0, 0.55)),
    url("../assets/background.webp") center / cover no-repeat,
    #031200;
  color: var(--keno-text);
}

.keno-app *,
.keno-app *::before,
.keno-app *::after {
  box-sizing: border-box;
}

.keno-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  flex: 0 0 auto;
}

.keno-brand {
  font-weight: 800;
  font-size: 28px;
  letter-spacing: 0.12em;
  color: var(--keno-green);
  text-shadow: 0 0 8px #99ff00, 0 0 18px #3cff00;
  line-height: 1;
}

.keno-disclaimer {
  flex: 1 1 180px;
  margin: 0;
  font-size: 11px;
  line-height: 1.35;
  color: #f4ffbf;
  text-transform: uppercase;
}

.keno-top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.keno-layout {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) 84px;
  gap: 8px;
  align-items: start;
  flex: 0 1 auto;
  min-height: 0;
  position: relative;
  z-index: 1;
}

.keno-panel {
  background: var(--keno-panel);
  border: 2px solid var(--keno-green);
  border-radius: 18px;
  padding: 8px 6px;
  min-height: 0;
}

.keno-panel h2 {
  margin: 0 0 8px;
  color: var(--keno-green);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-align: center;
}

.keno-pay-body div,
.keno-hits li {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  font-size: 13px;
  color: #fff;
  padding: 2px 4px;
  border-bottom: 1px solid rgba(153, 255, 0, 0.2);
}

.keno-hits {
  list-style: none;
  margin: 0;
  padding: 0;
}

.keno-board {
  display: grid;
  grid-template-columns: repeat(var(--cols, 10), minmax(0, 1fr));
  gap: 2px;
  background: #000;
  border: 2px solid #4a4a4a;
  padding: 3px;
}

.keno-cell {
  position: relative;
  aspect-ratio: 1;
  min-height: 28px;
  margin: 0;
  padding: 0;
  border: 1px solid #2a2a2a;
  background: #000;
  color: #9a9a9a;
  font-weight: 700;
  font-size: clamp(11px, 2.4cqw, 16px);
  font-family: Arial, Helvetica, sans-serif;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.keno-cell:focus-visible {
  outline: 2px solid var(--keno-green);
  outline-offset: -2px;
  z-index: 2;
}

.keno-cell .keno-num {
  position: relative;
  z-index: 1;
}

.keno-cell .keno-mark {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35em;
  font-weight: 900;
  pointer-events: none;
}

.keno-cell.is-selected {
  color: var(--keno-yellow);
  box-shadow: inset 0 0 0 2px var(--keno-yellow);
}

.keno-cell.is-selected .keno-num {
  font-weight: 800;
}

.keno-cell.is-drawn {
  color: #bbb;
}

.keno-cell.is-drawn .keno-mark {
  color: var(--keno-red);
  text-shadow: 0 0 0 #fff, 1px 0 #fff, -1px 0 #7a0000;
}

.keno-cell.is-match {
  color: var(--keno-yellow);
  box-shadow: inset 0 0 0 2px var(--keno-yellow);
}

.keno-cell.is-match .keno-num {
  z-index: 2;
}

.keno-cell.is-match .keno-mark {
  color: transparent;
  border: 3px solid var(--keno-red);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--keno-red);
  margin: 8%;
}

.keno-cell.is-match::after {
  content: "HIT";
  position: absolute;
  right: 2px;
  bottom: 1px;
  z-index: 2;
  font-size: 7px;
  letter-spacing: 0.04em;
  color: #fff;
  background: var(--keno-red);
  padding: 0 2px;
  line-height: 1.2;
}

.keno-balls {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 4px;
  margin-top: 8px;
}

.keno-ball {
  background: #111;
  border: 1px solid #355;
  border-radius: 8px;
  text-align: center;
  padding: 3px 2px;
  min-height: 38px;
}

.keno-ball-label {
  display: block;
  font-size: 8px;
  color: #8bb;
  letter-spacing: 0.04em;
}

.keno-ball-num {
  display: block;
  font-size: 14px;
  font-weight: 800;
  color: #cfcfcf;
}

.keno-ball.is-filled .keno-ball-num {
  color: var(--keno-green);
}

.keno-ball.is-match {
  border-color: var(--keno-red);
  background: #2a0000;
}

.keno-ball.is-match .keno-ball-num {
  color: var(--keno-yellow);
}

.keno-hud {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin: 0;
  flex: 0 0 auto;
  background: var(--keno-panel);
  border: 2px solid var(--keno-green);
  border-radius: 16px;
  padding: 6px 8px;
}

.keno-hud div {
  text-align: center;
}

.keno-hud span {
  display: block;
  color: var(--keno-green);
  font-size: 10px;
  letter-spacing: 0.08em;
}

.keno-hud strong {
  display: block;
  color: var(--keno-yellow);
  font-size: 20px;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 6px #665500;
}

.keno-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  position: relative;
  z-index: 3;
  flex: 0 0 auto;
  margin-top: 0;
  background: rgba(0, 0, 0, 0.88);
  border: 2px solid var(--keno-green);
  border-radius: 12px;
  padding: 8px;
}

.keno-controls button,
.keno-icon-btn,
.keno-dialog-actions button {
  margin: 0;
  border: 1px solid #3a2208;
  border-radius: 3px;
  background: linear-gradient(#8a5722, #5a340f);
  color: var(--keno-yellow);
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.04em;
  padding: 8px 10px;
  cursor: pointer;
  touch-action: manipulation;
  min-height: 36px;
}

.keno-controls button:focus-visible,
.keno-icon-btn:focus-visible,
.keno-dialog-actions button:focus-visible,
.keno-cell:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 1px;
}

.keno-controls button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.keno-play {
  margin-left: auto;
  min-width: 88px;
  background: linear-gradient(#c48a2a, #7a4a10);
  font-size: 16px;
}

.keno-bet {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--keno-yellow);
  font-weight: 800;
}

.keno-status {
  min-height: 22px;
  margin: 8px 0 0;
  text-align: center;
  font-size: 16px;
  font-weight: 800;
  color: var(--keno-yellow);
  text-transform: uppercase;
}

.keno-toast {
  position: sticky;
  bottom: 8px;
  margin: 8px auto 0;
  width: fit-content;
  max-width: 96%;
  background: #111;
  color: #fff;
  border: 2px solid var(--keno-yellow);
  border-radius: 8px;
  padding: 8px 14px;
  font-weight: 800;
  letter-spacing: 0.05em;
}

.keno-overlay,
.keno-confirm {
  display: none;
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: rgba(0, 0, 0, 0.72);
  align-items: center;
  justify-content: center;
  padding: 12px;
  z-index: 5;
  pointer-events: none;
}

.keno-overlay.is-open,
.keno-confirm.is-open {
  display: flex;
  pointer-events: auto;
}

.keno-overlay[hidden],
.keno-confirm[hidden],
.keno-toast[hidden] {
  display: none !important;
}

.keno-dialog {
  background: #0b1408;
  border: 2px solid var(--keno-green);
  border-radius: 12px;
  padding: 16px;
  max-width: 560px;
  max-height: 90%;
  overflow: auto;
  width: 100%;
  color: #e8ffd0;
}

.keno-dialog h2 {
  margin: 0 0 8px;
  color: var(--keno-green);
}

.keno-dialog table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.keno-dialog th,
.keno-dialog td {
  border-bottom: 1px solid #355;
  padding: 4px;
  text-align: left;
}

.keno-dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.keno-note {
  font-size: 12px;
  color: #cfe;
}

.keno-debug {
  margin: 8px;
  background: #111;
  color: #9f9;
  border: 1px solid #3a3;
  padding: 8px;
  font: 12px/1.4 Consolas, monospace;
}

.keno-debug pre {
  white-space: pre-wrap;
}

.keno-fatal {
  padding: 16px;
  color: #fff;
}

.is-narrow .keno-layout {
  grid-template-columns: 1fr;
}

.is-narrow .keno-panel {
  border-radius: 10px;
}

.is-narrow .keno-pay-body,
.is-narrow .keno-hits {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.is-narrow .keno-hud strong {
  font-size: 16px;
}

.is-compact .keno-brand {
  font-size: 22px;
}

.is-compact .keno-cell {
  min-height: 26px;
}

.is-compact .keno-cell.is-match::after {
  display: none;
}

.is-compact .keno-balls {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.is-compact .keno-hud {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.is-compact .keno-play {
  margin-left: 0;
  width: 100%;
}

@media (max-width: 360px) {
  .keno-cell {
    font-size: 11px;
  }
}
