/* RealityCircle for the web. Everything is white on black, like the iOS app. */

:root {
  color-scheme: dark;
  --fg: #ffffff;
  --bg: #000000;
  --track: #595959;          /* UIColor(white: 0.35) */
  --dim: 0.35;               /* alpha of a disabled control */
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

#safe-probe {
  position: fixed;
  visibility: hidden;
  pointer-events: none;
  padding-top: env(safe-area-inset-top, 0px);
  padding-right: env(safe-area-inset-right, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: env(safe-area-inset-left, 0px);
}

/* The square 3D view. Its frame is set by layout() in game.js. */
#stage {
  position: absolute;
  touch-action: none;
}
#stage canvas {
  display: block;
  width: 100%;
  height: 100%;
}
#fade {
  position: absolute;
  inset: 0;
  background: #000;
  opacity: 0;
  pointer-events: none;
}

/* The one-time "you can tilt and turn the table" banner, along the top of the table. */
#tilt-banner {
  position: absolute;
  left: 50%;
  top: 14px;
  width: max-content;
  max-width: calc(100% - 32px);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.72);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: #fff;
  font: 400 13px/1.35 var(--font);
  text-align: left;
  cursor: pointer;
  opacity: 0;
  transform: translate(-50%, -8px);
  transition: opacity 0.4s ease, transform 0.4s ease;
  pointer-events: none;
}
#tilt-banner.shown {
  opacity: 1;
  transform: translate(-50%, 0);
  pointer-events: auto;
}
#tilt-banner strong { font-weight: 600; font-size: 14px; }
#tilt-banner svg {
  width: 26px;
  height: 26px;
  flex: none;
  fill: none;
  stroke: #fff;
  stroke-width: 1.8;
  stroke-linejoin: round;
  stroke-linecap: round;
}

/* The scoreboard. Each .cell is placed by layout() in game.js. */
#board {
  position: absolute;
  background: var(--bg);
}
.cell {
  position: absolute;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}
.legend {
  flex: 0 0 35%;
  box-sizing: border-box;
  padding: 2px 2px 0;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.value {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.control {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

.box-button {
  font: 600 15px var(--font);
  color: var(--fg);
  background: transparent;
  border: 1px solid var(--fg);
  border-radius: 6px;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
}
.box-button:active:not(:disabled) { background: rgba(255, 255, 255, 0.15); }
.box-button:disabled, .disabled { opacity: var(--dim); cursor: default; }
.box-button:focus-visible { outline: 2px solid #4da3ff; outline-offset: 2px; }

#cell-reset .box-button { position: absolute; }

.aim-buttons {
  flex: 1;
  display: flex;
  gap: 8px;
  padding: 3px 6px;
  min-height: 0;
}
.aim-buttons .box-button {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
}
.aim-buttons svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* The sound switch, drawn to look like a UISwitch. */
.switch {
  position: relative;
  width: 51px;
  height: 31px;
  flex: none;
  cursor: pointer;
}
.switch input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.switch .knob {
  position: absolute;
  inset: 0;
  border-radius: 16px;
  background: var(--track);
  transition: background 0.2s;
  pointer-events: none;
}
.switch .knob::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s;
}
.switch input:checked + .knob { background: #34c759; }
.switch input:checked + .knob::after { transform: translateX(20px); }
.switch input:focus-visible + .knob { outline: 2px solid #4da3ff; outline-offset: 2px; }

/* The power slider: the thumb stays exactly under the finger. */
#power-slider {
  position: relative;
  height: 100%;
  touch-action: none;
  cursor: pointer;
}
#power-slider .track, #power-slider .fill {
  position: absolute;
  left: 0;
  top: 50%;
  height: 6px;
  margin-top: -3px;
  border-radius: 3px;
}
#power-slider .track { right: 0; background: var(--track); }
#power-slider .fill { width: 15px; background: #fff; }
#power-slider .thumb {
  position: absolute;
  top: 50%;
  left: 0;
  width: 30px;
  height: 30px;
  margin: -15px 0 0 -15px;
  border-radius: 50%;
  background: #fff;
}
#power-slider.animated .fill { transition: width 0.25s ease-in-out; }
#power-slider.animated .thumb { transition: transform 0.25s ease-in-out; }

/* Alerts, styled like an iOS alert. */
#dialog {
  width: min(300px, calc(100vw - 48px));
  max-height: calc(100vh - 48px);
  padding: 0;
  border: none;
  border-radius: 14px;
  background: rgba(40, 40, 42, 0.97);
  color: #fff;
  text-align: center;
  overflow: auto;
}
#dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
#dialog h2 {
  margin: 20px 16px 4px;
  font-size: 17px;
  font-weight: 600;
}
#dialog-message {
  margin: 0 16px 18px;
  font-size: 13px;
  line-height: 1.38;
  white-space: pre-line;
}
.dialog-buttons {
  display: flex;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
}
.dialog-buttons button {
  flex: 1;
  padding: 11px 8px;
  font: 400 17px var(--font);
  color: #0a84ff;
  background: none;
  border: none;
  cursor: pointer;
}
.dialog-buttons button + button { border-left: 1px solid rgba(255, 255, 255, 0.15); }
.dialog-buttons button.preferred { font-weight: 600; }
.dialog-buttons button.destructive { color: #ff453a; }
.dialog-buttons button:hover { background: rgba(255, 255, 255, 0.06); }
