:root {
  --bg: #0f172a;
  --sidebar: #1e293b;
  --accent: #6366f1;
  --text: #f8fafc;
  --text-dim: #94a3b8;
  --gold: linear-gradient(135deg, #fbbf24 0%, #d97706 100%);
  --silver: linear-gradient(135deg, #94a3b8 0%, #475569 100%);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Inter", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  overflow-y: auto;
}

.premium-app {
  display: flex;
  height: 100vh;
  position: relative;
}

/* Sidebar */
.control-sidebar {
  width: 320px;
  background: var(--sidebar);
  padding: 40px 24px;
  display: flex;
  flex-direction: column;
  gap: 32px;
  border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-logo {
  width: 40px;
  height: 40px;
}
.brand h2 {
  font-size: 1.1rem;
  font-weight: 800;
}
.brand p {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.control-group label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  font-weight: 700;
}

.p-btn {
  padding: 14px;
  border: none;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.p-btn-primary {
  background: var(--accent);
  color: white;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
}
.p-btn-primary:hover {
  transform: translateY(-2px);
  filter: brightness(1.1);
}

.p-btn-outline {
  background: transparent;
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.p-btn-outline:hover {
  background: rgba(255, 255, 255, 0.05);
}

.p-input-wrapper {
  display: flex;
  gap: 8px;
}
.p-input {
  flex: 1;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  color: white;
  padding: 10px;
  text-align: center;
  font-weight: 700;
}

.p-btn-add {
  width: 50px;
  background: #10b981;
  border: none;
  border-radius: 10px;
  color: white;
  font-size: 1.4rem;
  cursor: pointer;
}

/* Toggle */
.p-toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: var(--text-dim);
}
.p-switch {
  position: relative;
  width: 40px;
  height: 22px;
}
.p-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.p-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #334155;
  border-radius: 20px;
  transition: 0.3s;
}
.p-slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background: white;
  transition: 0.3s;
  border-radius: 50%;
}
input:checked + .p-slider {
  background: var(--accent);
}
input:checked + .p-slider:before {
  transform: translateX(18px);
}

/* Arena */
.arena {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  background: #0c111d;
}
.arena-toolbar {
  padding: 20px 40px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.status-indicator {
  font-size: 0.75rem;
  color: #10b981;
  font-weight: 600;
  letter-spacing: 0.5px;
}
.icon-tool {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-dim);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.75rem;
}

.coin-surface {
  flex: 1;
  padding: 40px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 40px;
  overflow-y: auto;
  justify-items: center;
  align-content: start;
}

/* PREMIUN COIN PHYSICS */
.coin {
  width: 130px;
  height: 130px;
  position: relative;
  transform-style: preserve-3d;
  cursor: pointer;
  transition: transform 0.1s;
}

.coin:active {
  transform: scale(0.92);
}

.coin .side {
  width: 100%;
  height: 100%;
  position: absolute;
  backface-visibility: hidden;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.1rem;
  border: 6px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), inset 0 0 20px rgba(0, 0, 0, 0.2);
}

.heads {
  background: var(--gold);
  color: #78350f;
}
.tails {
  background: var(--silver);
  color: #f8fafc;
  transform: rotateY(180deg);
}

/* ANIMATIONS */
@keyframes spin-animation {
  0% {
    transform: rotateY(0) rotateX(0);
  }
  100% {
    transform: rotateY(7200deg) rotateX(7200deg);
  }
}

@keyframes toss-animation {
  0% {
    transform: translateY(0) rotateX(0);
  }
  30% {
    transform: translateY(-250px) rotateX(720deg) scale(1.2);
  }
  100% {
    transform: translateY(0) rotateX(1800deg) scale(1);
  }
}

/* Stats */
.floating-stats {
  position: absolute;
  bottom: 30px;
  right: 30px;
  background: rgba(30, 41, 59, 0.8);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  padding: 10px 30px;
  border-radius: 20px;
  display: flex;
  gap: 40px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: var(--shadow-lg);
}

.stat {
  display: flex;
  flex-direction: column;
}
.stat small {
  font-size: 0.65rem;
  color: var(--text-dim);
  text-transform: uppercase;
  font-weight: 700;
}
.stat strong {
  font-size: 1.3rem;
  color: var(--text);
}
.stat.active strong {
  color: var(--accent);
}

/* Full Screen Overrides */
.coin-container.full-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: #000;
  z-index: 2000;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
}

/* MOBILE */
@media (max-width: 850px) {
  .premium-app {
    flex-direction: column;
  }
  .control-sidebar {
    width: 100%;
    padding: 20px;
    order: 2;
    height: auto;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
  }
  .arena {
    order: 1;
    flex: 1;
  }
  .floating-stats {
    position: static;
    width: 100%;
    border-radius: 0;
    justify-content: space-around;
    padding: 15px;
    order: 3;
  }
  .coin-surface {
    padding: 20px;
    grid-template-columns: repeat(2, 1fr);
  }
  .coin {
    width: 100px;
    height: 100px;
  }
}

.material-picker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  background: rgba(0, 0, 0, 0.2);
  padding: 4px;
  border-radius: 10px;
}

.m-btn {
  padding: 8px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  font-weight: 600;
  transition: 0.3s;
}

.m-btn.active {
  background: var(--accent);
  color: white;
}

/* Metallic Profiles */
.coin.gold .heads {
  background: linear-gradient(135deg, #fbbf24 0%, #d97706 100%);
  color: #78350f;
  border-color: #fde68a;
}
.coin.gold .tails {
  background: #451a03;
  color: #fbbf24;
  border-color: #78350f;
}

.coin.silver .heads {
  background: linear-gradient(135deg, #e2e8f0 0%, #94a3b8 100%);
  color: #1e293b;
  border-color: #f8fafc;
}
.coin.silver .tails {
  background: #334155;
  color: #e2e8f0;
  border-color: #475569;
}

/* Fullscreen Styles */
:fullscreen .arena {
  height: 100vh;
  width: 100vw;
}
:fullscreen .control-sidebar {
  display: none;
}
:fullscreen .floating-stats {
  bottom: 20px;
  right: 20px;
  scale: 0.8;
}

/* Centering & Premium Layout */
.coin-surface {
  flex: 1;
  padding: 40px;
  display: flex;
  flex-wrap: wrap;
  gap: 30px;
  justify-content: center;
  align-items: center;
  overflow-y: auto;
  background: radial-gradient(circle at center, #111827 0%, #000 100%);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-content: center;
  align-items: center;
  gap: 40px;
}

.coin {
  width: 130px;
  height: 130px;
  position: relative;
  transform-style: preserve-3d;
  cursor: pointer;
  transition: transform 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Restored Animation Logic - Ensuring Tails lands on 180deg */
@keyframes toss-heads {
  0% {
    transform: translateY(0) rotateX(0);
  }
  30% {
    transform: translateY(-300px) rotateX(720deg) scale(1.2);
  }
  100% {
    transform: translateY(0) rotateX(1800deg);
  }
}

@keyframes toss-tails {
  0% {
    transform: translateY(0) rotateX(0);
  }
  30% {
    transform: translateY(-300px) rotateX(720deg) scale(1.2);
  }
  100% {
    transform: translateY(0) rotateX(1980deg);
  }
}

@keyframes spin-heads {
  0% {
    transform: rotateY(0);
  }
  100% {
    transform: rotateY(6480deg);
  }
}

@keyframes spin-tails {
  0% {
    transform: rotateY(0);
  }
  100% {
    transform: rotateY(6300deg);
  }
}

/* Mobile Drawer Styles */
.drawer-toggle {
  display: none;
  position: absolute;
  top: 20px;
  left: 20px;
  z-index: 3000;
  background: var(--accent);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 50px;
  font-weight: 800;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

@media (max-width: 850px) {
  .drawer-toggle {
    display: block;
  }
  .control-sidebar {
    position: fixed;
    left: 0;
    bottom: -100%; /* Hidden by default */
    width: 100%;
    height: auto;
    z-index: 2500;
    transition: bottom 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 30px 30px 0 0;
    border-top: 2px solid var(--accent);
  }
  .control-sidebar.open {
    bottom: 0;
  }
}

/* Accessibility Focus Styles */
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 4px;
}

.coin:focus-visible {
  outline-offset: 10px;
  border-radius: 50%;
}

/* ---------- Guide / article content below the app ---------- */
.content-wrap {
  max-width: 900px;
  margin: 0 auto;
  padding: 40px 20px 20px;
}

.content-card {
  background: var(--sidebar);
  border: 1px solid rgba(148, 163, 184, 0.15);
  border-radius: 16px;
  padding: 32px;
  box-shadow: var(--shadow-lg);
  line-height: 1.8;
}

.content-card h2 {
  font-size: 1.6rem;
  margin-bottom: 10px;
}

.content-card h2 span {
  color: var(--accent);
}

.content-card h3 {
  font-size: 1.15rem;
  color: var(--accent);
  margin: 28px 0 10px;
}

.content-card h4 {
  font-size: 1rem;
  margin: 18px 0 6px;
}

.content-card p,
.content-card li {
  color: var(--text-dim);
  font-size: 0.98rem;
  margin-bottom: 12px;
}

.content-card ul,
.content-card ol {
  padding-left: 22px;
  margin-bottom: 14px;
}

.content-card li {
  margin-bottom: 8px;
}

.content-card strong {
  color: var(--text);
}

.content-card a {
  color: var(--accent);
  text-decoration: none;
}

.content-card a:hover {
  text-decoration: underline;
}

.site-footer {
  text-align: center;
  padding: 24px 20px 36px;
  color: var(--text-dim);
  font-size: 0.9rem;
}

.site-footer a {
  color: var(--accent);
  text-decoration: none;
  margin: 0 10px;
}

.site-footer a:hover {
  text-decoration: underline;
}

.creator-credit {
  margin-top: 24px;
  text-align: center;
}

.creator-credit a {
  color: var(--text-dim);
  font-size: 0.8rem;
  text-decoration: none;
}

.creator-credit a:hover {
  color: var(--accent);
  text-decoration: underline;
}
