/* =========================
   FALLOUT-STYLE CRT TERMINAL UI
   ========================= */

:root{
  --bg:#000;
  --fg:#b8ffcc;
  --muted:#63c98a;
  --accent:#33ff77;

  --shadow: rgba(0,0,0,0.65);
  --glow: rgba(51,255,119,0.12);

  --pad: 14px;
  --wrap: 980px;

  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono","Courier New", monospace;
}

*{ box-sizing:border-box; }
html{ scroll-behavior:smooth; }

body{
  margin:0;
  background:var(--bg);
  color:var(--fg);
  font:16px/1.55 var(--mono);
  text-rendering: geometricPrecision;
  min-height:100vh;
  overflow-x:hidden;
  text-shadow:
    0 0 6px rgba(51,255,119,0.25),
    0 0 14px rgba(51,255,119,0.12);
}

a{ color:var(--accent); text-decoration:none; }
a:hover{ text-decoration:underline; }

/* CRT overlays */
body::before{
  content:"";
  position:fixed;
  inset:0;
  pointer-events:none;
  background:
    radial-gradient(circle at 50% 45%,
      rgba(0,0,0,0) 0 55%,
      rgba(0,0,0,0.35) 75%,
      rgba(0,0,0,0.78) 100%),
    repeating-linear-gradient(
      to bottom,
      rgba(0,0,0,0.00) 0px,
      rgba(0,0,0,0.00) 2px,
      rgba(0,0,0,0.10) 3px
    );
  opacity:0.75;
  mix-blend-mode:multiply;
  z-index:9999;
  animation: crtFlicker 5s infinite;
}

@keyframes crtFlicker{
  0%,100%{ opacity:0.75; }
  50%{ opacity:0.70; }
  52%{ opacity:0.78; }
  60%{ opacity:0.73; }
}

body::after{
  content:"";
  position:fixed;
  inset:-20%;
  pointer-events:none;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='.25'/%3E%3C/svg%3E");
  opacity:0.06;
  mix-blend-mode:overlay;
  animation: noiseMove 1.2s steps(2,end) infinite;
  z-index:9998;
}

@keyframes noiseMove{
  0%{ transform:translate(0,0); }
  100%{ transform:translate(-10%, -10%); }
}

/* layout */
.wrap{
  width:100%;
  min-height:100vh;
  margin:0;
  padding:24px;
  display:grid;
  place-items:center;
  position:relative;
}

.layout-row{
  width: min(calc(var(--wrap) + 340px), calc(100vw - 48px));
  display:flex;
  gap:18px;
  align-items:stretch;
  justify-content:center;
}

.layout-row .ui-frame{
  flex: 1 1 auto;
  min-width: 0;
}

.tama-device{
  width: 320px;
  flex: 0 0 320px;
  display:flex;
  align-items:stretch;
}

@media (max-width: 980px){
  .layout-row{
    width: calc(100vw - 28px);
    flex-direction:column;
  }
  .tama-device{
    width: 100%;
    flex: 0 0 auto;
  }
}

/* main ui */
.ui-frame{
  width:min(var(--wrap), calc(100vw - 48px));
  min-height:calc(100vh - 48px);
  position:relative;
  background:linear-gradient(180deg, rgba(4,20,11,0.92), rgba(2,10,5,0.92));
  padding:var(--pad);
  box-shadow: 0 18px 60px rgba(0,0,0,0.75), 0 0 26px rgba(51,255,119,0.12);
  border-radius:10px;
  transform: perspective(900px) rotateX(1.2deg) scale(1.01);
  transform-origin:center;
  backface-visibility:hidden;
  filter: saturate(1.05) contrast(1.05);
}

.ui-frame::after{
  content:"";
  position:absolute;
  inset:0;
  pointer-events:none;
  background:linear-gradient(135deg,
    rgba(255,255,255,0.06) 0%,
    rgba(255,255,255,0.02) 18%,
    rgba(255,255,255,0.00) 45%,
    rgba(255,255,255,0.00) 100%);
  mix-blend-mode:screen;
  opacity:0.35;
  border-radius:10px;
}

.ui-titlebar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:8px 10px;
  margin:calc(var(--pad) * -1) calc(var(--pad) * -1) 12px;
  background:rgba(0,0,0,0.45);
  border-bottom:1px solid rgba(51,255,119,0.20);
  position:relative;
  z-index:2;
}

.ui-title{
  display:flex;
  align-items:center;
  gap:10px;
  color:var(--muted);
  font-size:13px;
  letter-spacing:1px;
  text-transform:uppercase;
}

.ui-dot{
  width:12px;
  height:12px;
  background:var(--accent);
  box-shadow:0 0 18px rgba(51,255,119,0.35);
  display:inline-block;
  animation:cc-blink 1.1s steps(1,end) infinite;
}

@keyframes cc-blink{
  0%,55%{ opacity:1; }
  56%,100%{ opacity:0.15; }
}

.ui-tabs{
  display:flex;
  flex-wrap:wrap;
  gap:6px;
  justify-content:flex-end;
}

.ui-btn{
  display:inline-block;
  padding:7px 9px;
  color:var(--fg);
  background:rgba(0,0,0,0.30);
  border:1px solid rgba(51,255,119,0.22);
  text-transform:lowercase;
  letter-spacing:0.5px;
}

.ui-btn:hover{ background:rgba(51,255,119,0.08); text-decoration:none; }
.ui-btn.active{ border-color:rgba(51,255,119,0.55); }
.ui-btn.is-hidden{ display:none; }

.ui-section{
  margin-top:12px;
  padding:12px;
  background:rgba(0,0,0,0.22);
  border:1px solid rgba(51,255,119,0.14);
  box-shadow:0 0 18px rgba(51,255,119,0.06);
  position:relative;
  z-index:2;
  filter: blur(0.15px);
}

.ui-h1{ margin:0 0 8px; font-size:28px; letter-spacing:0.5px; }
.ui-muted{ color:var(--muted); }

.ui-menu{
  display:flex;
  flex-direction:column;
  gap:10px;
  margin-top:10px;
}

.ui-item{
  position:relative;
  display:flex;
  justify-content:flex-start;
  gap:12px;
  align-items:baseline;
  padding:10px 10px;
  background:rgba(0,0,0,0.22);
  border:1px solid rgba(51,255,119,0.14);
}

.ui-item:hover{
  background:rgba(51,255,119,0.08);
  text-decoration:none;
  box-shadow:0 0 14px rgba(51,255,119,0.10);
}

.ui-item::before{
  content:">";
  color:rgba(51,255,119,0.65);
  margin-right:10px;
  opacity:0;
}
.ui-item:hover::before{ opacity:1; }

.ui-item.selected{
  background:rgba(51,255,119,0.10);
  border-color:rgba(51,255,119,0.25);
  box-shadow:0 0 18px rgba(51,255,119,0.12);
}
.ui-item.selected::before{ opacity:1; }

.ui-k{ color:var(--accent); letter-spacing:1px; }
.is-hidden{ display:none; }

.ui-footer{
  margin-top:12px;
  display:flex;
  justify-content:space-between;
  gap:12px;
  flex-wrap:wrap;
  color:var(--muted);
  font-size:13px;
  position:relative;
  z-index:2;
}

/* bottom-left button */
.process-btn{
  position:fixed;
  left:18px;
  bottom:18px;
  z-index:10002;
  display:inline-block;
  padding:10px 12px;
  background:rgba(0,0,0,0.55);
  border:1px solid rgba(51,255,119,0.20);
  color:var(--fg);
  letter-spacing:1px;
  text-transform:uppercase;
}

.process-btn:hover{
  background:rgba(51,255,119,0.08);
  text-decoration:none;
}

/* chromatic aberration */
.ui-frame *{
  text-shadow:
    0 0 10px rgba(51,255,119,0.10),
    1px 0 rgba(0,255,160,0.08),
   -1px 0 rgba(0,120,80,0.06);
}

/* CAU device */
.tama-shell{
  width:100%;
  position:relative;
  border-radius:14px;
  background: linear-gradient(180deg, rgba(0,0,0,0.55), rgba(0,0,0,0.28));
  border: 1px solid rgba(51,255,119,0.20);
  box-shadow: 0 18px 60px rgba(0,0,0,0.65), 0 0 26px rgba(51,255,119,0.10);
  overflow:hidden;
  filter: saturate(1.05) contrast(1.05);
}

.tama-shell::after{
  content:"";
  position:absolute;
  inset:0;
  pointer-events:none;
  background: linear-gradient(135deg,
    rgba(255,255,255,0.08) 0%,
    rgba(255,255,255,0.02) 20%,
    rgba(255,255,255,0.00) 48%,
    rgba(255,255,255,0.00) 100%);
  mix-blend-mode: screen;
  opacity: 0.22;
}

.tama-topbar{
  display:flex;
  align-items:center;
  gap:10px;
  padding:10px 12px;
  background: rgba(0,0,0,0.60);
  border-bottom: 1px solid rgba(51,255,119,0.18);
  position:relative;
  z-index:2;
}

.tama-led{
  width:10px;
  height:10px;
  border-radius:3px;
  background: var(--accent);
  box-shadow: 0 0 14px rgba(51,255,119,0.35);
  opacity: 0.85;
}

.tama-label{
  color: var(--muted);
  letter-spacing: 1px;
  text-transform: uppercase;
  font-size: 12px;
  flex: 1 1 auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tama-chip{
  padding:3px 8px;
  border: 1px solid rgba(51,255,119,0.22);
  background: rgba(0,0,0,0.35);
  color: var(--accent);
  font-size: 12px;
  letter-spacing: 1px;
}

.tama-screen{
  padding:12px;
  background: linear-gradient(180deg, rgba(2,12,6,0.92), rgba(0,0,0,0.92));
  border-bottom: 1px solid rgba(51,255,119,0.14);
}

.tama-screen-inner{
  border-radius:10px;
  border: 1px solid rgba(51,255,119,0.16);
  background: rgba(0,0,0,0.22);
  box-shadow:
    inset 0 0 0 1px rgba(0,0,0,0.55),
    0 0 18px rgba(51,255,119,0.06);
  overflow:hidden;
  position:relative;
}

.tama-screen-inner::after{
  content:"";
  position:absolute;
  inset:0;
  pointer-events:none;
  background: radial-gradient(circle at 50% 45%,
    rgba(0,0,0,0) 0 55%,
    rgba(0,0,0,0.22) 78%,
    rgba(0,0,0,0.55) 100%);
  mix-blend-mode:multiply;
  opacity:0.65;
}

.tama-img{
  width:100%;
  height:230px;
  display:block;
  object-fit:cover;
}

/* feed button */
.tama-feed{
  margin-top:10px;
  width:100%;
  padding:10px 10px;
  background: rgba(0,0,0,0.30);
  border: 1px solid rgba(51,255,119,0.22);
  color: var(--fg);
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor:pointer;
  font: inherit;
}

.tama-feed:hover{ background: rgba(51,255,119,0.08); }
.tama-feed.is-fed{
  border-color: rgba(51,255,119,0.55);
  color: var(--accent);
  background: rgba(51,255,119,0.06);
}

.tama-status{
  padding:12px;
  background: rgba(0,0,0,0.38);
}

.tama-row{
  display:flex;
  justify-content:space-between;
  gap:10px;
  padding:8px 10px;
  border: 1px solid rgba(51,255,119,0.12);
  background: rgba(0,0,0,0.22);
  margin-bottom:8px;
}

.tama-row:last-child{ margin-bottom:0; }

.tama-k{
  color: var(--muted);
  letter-spacing: 1px;
  font-size: 12px;
  text-transform: uppercase;
}

.tama-v{
  color: var(--fg);
  letter-spacing: 0.5px;
  font-size: 13px;
  text-align:right;
}

.tama-note .tama-v{
  max-width:190px;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

/* daily updates */
.tama-log{
  padding:12px;
  background: rgba(0,0,0,0.34);
  border-top: 1px solid rgba(51,255,119,0.12);
}

.tama-log-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  margin-bottom:10px;
}

.tama-log-title{
  color: var(--muted);
  letter-spacing: 1px;
  text-transform: uppercase;
  font-size: 12px;
}

.tama-log-hint{
  color: rgba(99,201,138,0.85);
  font-size: 12px;
}

.tama-log-box{
  border: 1px solid rgba(51,255,119,0.14);
  background: rgba(0,0,0,0.22);
  border-radius:10px;
  padding:10px;
  max-height:170px;
  overflow:auto;
}

.tama-entry{
  padding:8px 6px;
  border-bottom: 1px solid rgba(51,255,119,0.10);
}
.tama-entry:last-child{ border-bottom:none; }

.tama-ts{
  color: rgba(99,201,138,0.95);
  font-size: 12px;
  letter-spacing: 0.5px;
  margin-bottom:4px;
}

.tama-msg{
  color: var(--fg);
  font-size: 13px;
  line-height: 1.35;
}

/* scrollbars */
.tama-log-box::-webkit-scrollbar{ width:10px; }
.tama-log-box::-webkit-scrollbar-track{ background: rgba(0,0,0,0.35); }
.tama-log-box::-webkit-scrollbar-thumb{
  background: rgba(51,255,119,0.18);
  border: 1px solid rgba(51,255,119,0.22);
}
.tama-log-box::-webkit-scrollbar-thumb:hover{
  background: rgba(51,255,119,0.26);
}

.tama-footer{
  display:flex;
  justify-content:space-between;
  gap:10px;
  padding:10px 12px;
  color:var(--muted);
  font-size:12px;
  border-top:1px solid rgba(51,255,119,0.12);
  background: rgba(0,0,0,0.45);
}

/* boot overlay */
.boot-screen{
  position:fixed;
  inset:0;
  z-index:10000;
  background:#000;
  display:grid;
  place-items:center;
}

.boot-box{
  width:min(980px, calc(100% - 28px));
  padding:16px;
  background:rgba(0,0,0,0.88);
  box-shadow:0 0 28px rgba(51,255,119,0.12), 0 18px 60px rgba(0,0,0,0.75);
  outline:1px solid rgba(51,255,119,0.20);
}

.boot-title{
  color:var(--muted);
  letter-spacing:2px;
  text-transform:uppercase;
  font-size:12px;
  margin-bottom:10px;
}

.boot-log{
  margin:0;
  color:var(--accent);
  font-size:13px;
  line-height:1.35;
  white-space:pre-wrap;
  word-break:break-word;
  min-height:240px;
  max-height:60vh;
  overflow:hidden;
}

.boot-log::after{
  content:"█";
  margin-left:6px;
  opacity:1;
  animation:bootBlink 0.6s steps(1) infinite;
}

.boot-screen.consent .boot-log::after{
  content:"";
  animation:none;
}

@keyframes bootBlink{ 50%{ opacity:0; } }

.boot-screen.gone{ animation:bootFade 0.35s ease forwards; }
@keyframes bootFade{ to{ opacity:0; } }

.boot-screen.nope .boot-box{ animation:denied 0.25s ease; }

@keyframes denied{
  0%{ transform:translateX(0); }
  25%{ transform:translateX(-6px); }
  50%{ transform:translateX(6px); }
  100%{ transform:translateX(0); }
}

/* mobile */
@media (max-width:860px){
  .ui-tabs{ justify-content:flex-start; }
  .wrap{ padding:14px; }
  .ui-frame{
    min-height:calc(100vh - 28px);
    transform: perspective(900px) rotateX(1deg) scale(1.01);
  }
}

/* accessibility */
@media (prefers-reduced-motion: reduce){
  body::before,
  body::after,
  .ui-dot,
  .boot-log::after{
    animation:none !important;
  }
  .ui-frame{
    transform:none;
  }
}

/* ====== BLACKJACK PAGE UI (scoped) ====== */
.bj-wrap{ width:min(1100px,94vw); margin:18px auto; }
.bj-panel{
  background: rgba(0,0,0,0.35);
  border: 1px solid rgba(51,255,119,0.18);
  box-shadow: 0 0 18px rgba(51,255,119,0.08);
  padding: 12px;
  border-radius: 10px;
}

.bj-titlebar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin-bottom:12px;
  padding-bottom:10px;
  border-bottom: 1px solid rgba(51,255,119,0.14);
}
.bj-title{
  display:flex; align-items:center; gap:10px;
  font-weight:700;
  letter-spacing: 0.06em;
}
.bj-dot{
  width:10px; height:10px; border-radius:50%;
  background: rgba(51,255,119,0.65);
  box-shadow: 0 0 10px rgba(51,255,119,0.25);
}
.bj-link{
  color: inherit;
  text-decoration:none;
  border-bottom: 1px dotted rgba(51,255,119,0.35);
}
.bj-link:hover{ border-bottom-style: solid; }

.bj-grid{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.bj-note{ margin-top: 8px; opacity: .85; font-size: 13px; }

.bet-table{
  margin:0; padding:10px;
  background: rgba(0,0,0,0.18);
  border: 1px solid rgba(51,255,119,0.14);
  border-radius:10px;
  white-space: pre;
  overflow:auto;
}
.betcell{
  cursor:pointer;
  user-select:none;
  display:inline-block;
  padding:0 1px;
  border-radius:6px;
  outline:1px solid transparent;
}
.betcell:hover{
  outline-color: rgba(51,255,119,0.35);
  background: rgba(51,255,119,0.08);
}

.hand{
  margin:0; padding:10px;
  background: rgba(0,0,0,0.18);
  border: 1px solid rgba(51,255,119,0.14);
  border-radius:10px;
  min-height:54px;
  white-space: pre-wrap;
}
.score{ margin-top:8px; opacity:.9; }

.controls.bj-controls{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  margin: 12px 0;
}

.btn{
  background: rgba(0,0,0,0.25);
  color: inherit;
  border: 1px solid rgba(51,255,119,0.22);
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
}
.btn:hover{ background: rgba(51,255,119,0.06); }
.btn:disabled{ opacity:.45; cursor:not-allowed; }
.btn.ghost{ border-style:dashed; }

.msg{
  margin:0; padding:10px;
  background: rgba(0,0,0,0.18);
  border: 1px solid rgba(51,255,119,0.14);
  border-radius:10px;
  min-height:90px;
  max-height:210px;
  overflow:auto;
  white-space: pre-wrap;
}

.bank{ display:grid; gap:6px; }
.num{ color: var(--accent); }

@media (max-width: 880px){
  .bj-grid{ grid-template-columns: 1fr; }
}
