/* src/app/styles.css */
:root {
  color: #172033;
  background: #f7f8fb;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Noto Sans, Ubuntu, Cantarell, Helvetica Neue, sans-serif;
  line-height: 1.5;
}

* {
  box-sizing: border-box;
}

body {
  overflow-x: hidden;
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
}

button {
  font: inherit;
}

.app-shell {
  width: calc(100% - 32px);
  max-width: 1120px;
  margin: 0 auto;
  padding: 48px 0;
}

.run-app-shell {
  padding: 24px 0;
}

.run-app-shell .hero {
  margin-bottom: 14px;
}

.run-app-shell h1 {
  margin-bottom: 8px;
  font-size: 2.5rem;
}

.run-app-shell .pwa-status, .run-app-shell .shell-nav {
  margin-bottom: 12px;
}

.hero {
  min-width: 0;
  margin-bottom: 28px;
}

.eyebrow {
  color: #4f46e5;
  text-transform: uppercase;
  margin: 0 0 8px;
  font-size: .875rem;
  font-weight: 700;
}

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

h1 {
  margin-bottom: 12px;
  font-size: clamp(2rem, 5vw, 3.75rem);
  line-height: 1;
}

.summary {
  color: #46546f;
  overflow-wrap: anywhere;
  min-width: 0;
  max-width: 640px;
  margin-bottom: 0;
}

.shell-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.pwa-status {
  display: flex;
  background: #fff;
  border: 1px solid #d7deea;
  border-radius: 8px;
  flex-wrap: wrap;
  align-items:  center;
  gap: 10px;
  margin-bottom: 18px;
  padding: 12px;
}

.status-pill {
  color: #14532d;
  background: #dcfce7;
  border: 1px solid #15803d;
  border-radius: 999px;
  margin: 0;
  padding: 4px 10px;
  font-weight: 800;
}

.status-pill.offline {
  color: #7a271a;
  background: #fee4e2;
  border-color: #b42318;
}

.status-copy {
  overflow-wrap: anywhere;
  min-width: 0;
  margin: 0;
}

.compact-update {
  margin-left: auto;
}

.nav-button {
  color: #1f2a44;
  cursor: pointer;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  min-height: 44px;
  padding: 10px 16px;
}

.nav-button:hover {
  outline: 3px solid #312e81;
  outline-offset: 2px;
  border-color: #4f46e5;
}

.nav-button:focus-visible {
  outline: 3px solid #312e81;
  outline-offset: 2px;
  border-color: #4f46e5;
}

.nav-button.active {
  color: #fff;
  background: #4f46e5;
  border-color: #4f46e5;
  box-shadow: inset 0 -4px #facc15;
}

.screen-panel {
  background: #fff;
  border: 1px solid #d7deea;
  border-radius: 8px;
  padding: 24px;
}

.screen-panel h2 {
  margin-bottom: 8px;
}

.screen-panel p {
  color: #46546f;
  margin-bottom: 0;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.primary-action, .secondary-action {
  cursor: pointer;
  border-radius: 8px;
  min-width: 44px;
  min-height: 44px;
  padding: 10px 16px;
}

.primary-action:focus-visible {
  outline: 3px solid #312e81;
  outline-offset: 2px;
}

.secondary-action:focus-visible {
  outline: 3px solid #312e81;
  outline-offset: 2px;
}

.primary-action {
  color: #fff;
  background: #4f46e5;
  border: 1px solid #4f46e5;
}

.secondary-action {
  color: #1f2a44;
  background: #fff;
  border: 1px solid #cbd5e1;
}

.primary-action:disabled, .secondary-action:disabled {
  cursor: not-allowed;
  opacity: .55;
}

.inline-error {
  color: #b42318;
  margin-top: 16px;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin: 16px 0 0;
}

.result-grid div {
  min-width: 0;
}

.result-grid dt {
  color: #46546f;
  font-size: .85rem;
  font-weight: 700;
}

.result-grid dd {
  color: #172033;
  margin: 4px 0 0;
  font-weight: 700;
}

.hash-value {
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Consolas, Liberation Mono, monospace;
  font-size: .9rem;
}

.run-board {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items:  start;
  gap: 16px;
  width: min(100%, 200vh - 616px);
  min-width: 0;
  margin: 0 auto;
}

.run-board-panel {
  display: flex;
  aspect-ratio: 1;
  overflow: auto;
  background: #fff;
  border: 1px solid #d7deea;
  border-radius: 8px;
  flex-direction: column;
  min-width: 0;
  padding: 18px;
}

.run-status-panel {
  gap: 16px;
}

.run-interaction-panel {
  gap: 0;
}

.run-header, .section-heading, .slot-item, .upgrade-item {
  display: flex;
  justify-content: space-between;
  align-items:  flex-start;
  gap: 16px;
}

.run-header {
  flex-wrap: wrap;
}

.run-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(90px, 1fr));
  gap: 12px;
  margin: 0;
}

.run-stats div {
  min-width: 0;
}

.run-stats dt {
  color: #46546f;
  font-size: .8rem;
  font-weight: 700;
}

.run-stats dd {
  color: #172033;
  margin: 2px 0 0;
  font-weight: 700;
}

.turn-guidance {
  color: #1e3a8a;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  padding: 12px;
  font-weight: 700;
}

.turn-message {
  color: #14532d;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  padding: 12px;
  font-weight: 800;
}

.run-section {
  border-top: 1px solid #e2e8f0;
  margin-top: 16px;
  padding-top: 16px;
}

.run-section h3, .run-section h4, .run-section h5, .run-interaction-panel > h3 {
  margin: 0;
}

.compact-actions {
  margin-top: 0;
}

.dice-tray {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.die-button {
  display: grid;
  color: #172033;
  text-align: left;
  cursor: pointer;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  gap: 6px;
  min-height: 132px;
  padding: 14px;
}

.die-button:hover {
  outline: 3px solid #312e81;
  outline-offset: 2px;
  border-color: #4f46e5;
}

.die-button:focus-visible {
  outline: 3px solid #312e81;
  outline-offset: 2px;
  border-color: #4f46e5;
}

.die-button[aria-pressed="true"] {
  border-color: #4f46e5;
  box-shadow: inset 0 0 0 2px #4f46e5;
}

.die-button[aria-pressed="true"] .dice-face-box {
  fill: #eef2ff;
  stroke: #4f46e5;
}

.die-button[data-die-state="assigned"] {
  background: #f0fdf4;
  border-color: #15803d;
}

.die-button[data-die-state="assigned"] .dice-face-box {
  fill: #dcfce7;
  stroke: #15803d;
}

.die-button[aria-pressed="true"] .die-state:first-of-type {
  color: #172033;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  font-weight: 800;
}

.die-name, .die-value {
  font-weight: 800;
}

.die-value {
  font-size: 1.4rem;
}

.die-state {
  color: #46546f;
  font-size: .9rem;
}

.dice-face {
  color: #172033;
  justify-self: center;
  width: min(100%, 74px);
  height: auto;
}

.dice-face-box {
  fill: #fff;
  stroke: #172033;
  stroke-width: 5;
}

.dice-pip {
  fill: currentColor;
}

.dice-placeholder-line {
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 7;
}

.dice-face[data-roll-transition="true"] .dice-face-box, .dice-face[data-roll-transition="true"] .dice-pip {
  animation: dice-face-pop .18s ease-out;
}

@keyframes dice-face-pop {
  0% {
    opacity: .65;
    transform: scale(.92);
    transform-origin: 50% 50%;
  }

  100% {
    opacity: 1;
    transform: scale(1);
    transform-origin: 50% 50%;
  }
}

.slot-list, .upgrade-list {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.slot-item, .upgrade-item {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 14px;
}

.slot-item {
  display: grid;
  grid-template-columns: minmax(120px, .8fr) minmax(160px, 1fr) auto;
  align-items: stretch;
}

.slot-dice-tray {
  display: flex;
  background: #f8fafc;
  border: 1px dashed #94a3b8;
  border-radius: 8px;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
  min-height: 72px;
  padding: 8px;
}

.slot-empty {
  color: #46546f;
  align-self:  center;
  margin: 0;
  font-weight: 700;
}

.slot-die {
  display: grid;
  color: #14532d;
  cursor: pointer;
  background: #f0fdf4;
  border: 1px solid #15803d;
  border-radius: 8px;
  gap: 4px;
  min-width: 92px;
  min-height: 96px;
  padding: 8px;
}

.slot-die:hover {
  outline: 3px solid #14532d;
  outline-offset: 2px;
}

.slot-die:focus-visible {
  outline: 3px solid #14532d;
  outline-offset: 2px;
}

.slot-dice-face {
  width: 48px;
}

.slot-remove-copy {
  color: #14532d;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  font-size: .8rem;
  font-weight: 800;
}

.slot-actions {
  display: grid;
  align-content:  start;
  gap: 8px;
}

.slot-item p, .upgrade-item p {
  margin: 6px 0 0;
}

.explanation-list {
  color: #46546f;
  margin: 12px 0 0;
  padding-left: 20px;
}

@media (max-width: 640px) {
  .app-shell {
    width: calc(100% - 20px);
    padding: 24px 0;
  }

  .run-app-shell {
    padding: 12px 0 0;
  }

  .run-app-shell h1 {
    margin-bottom: 0;
    font-size: 1.5rem;
  }

  .run-app-shell .hero {
    margin-bottom: 8px;
  }

  .run-app-shell .hero .eyebrow, .run-app-shell .hero .summary {
    display: none;
  }

  .run-app-shell .pwa-status, .run-app-shell .shell-nav {
    margin-bottom: 10px;
  }

  .pwa-status, .status-copy {
    min-width: 0;
  }

  .screen-panel {
    padding: 16px;
  }

  .run-screen {
    padding-bottom: 0;
  }

  .run-board {
    grid-template-columns: minmax(0, 1fr);
    width: min(100%, 316px);
  }

  .run-board-panel {
    aspect-ratio: 1;
    padding: 12px;
  }

  .run-header, .section-heading, .slot-item, .upgrade-item {
    display: grid;
  }

  .slot-item, .run-stats {
    grid-template-columns: 1fr;
  }
}

@media (orientation: portrait) and (max-width: 900px) {
  .run-board {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *:before, *:after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

@media (prefers-contrast: more) {
  :root {
    color: #000;
    background: #fff;
  }

  .summary, .die-state, .explanation-list, .result-grid dt, .run-stats dt, .turn-message, .turn-guidance {
    color: #111;
  }

  .nav-button, .primary-action, .secondary-action, .screen-panel, .run-board-panel, .die-button, .slot-die, .slot-item, .upgrade-item {
    border-color: #000;
  }
}

@media (forced-colors: active) {
  .nav-button, .primary-action, .secondary-action, .die-button {
    forced-color-adjust: auto;
  }

  .nav-button.active, .die-button[aria-pressed="true"] {
    outline: 2px solid buttontext;
    outline-offset: 2px;
    box-shadow: none;
  }

  .slot-die:focus-visible {
    outline: 2px solid buttontext;
    outline-offset: 2px;
    box-shadow: none;
  }

  .dice-face-box, .dice-placeholder-line {
    stroke: ButtonText;
  }

  .dice-face-box {
    fill: Canvas;
  }

  .dice-pip {
    fill: ButtonText;
  }
}
