/* Shared structural contract for touch-first Ultima I-VII game shells. */
[data-classic-ultima-shell] {
  --classic-shell-gap: 7px;
  --classic-shell-control-height: 194px;
  --classic-shell-surface: #030506;
  --classic-shell-control-surface: #080b10;
  touch-action: manipulation;
  --classic-ink: #080d16;
  --classic-panel: #0d1523;
  --classic-panel-raised: #121d2e;
  --classic-card: #101a28;
  --classic-line: #26364c;
  --classic-line-bright: #3b536e;
  --classic-text: #f0eadc;
  --classic-muted: #8f9cac;
  --classic-gold: #d5a84d;
  --classic-gold-bright: #f1cc78;
  --classic-green: #78b86b;
}

[data-classic-ultima-world] {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--classic-shell-surface);
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

[data-classic-ultima-world] canvas { image-rendering: pixelated; touch-action: manipulation; }
[data-classic-ultima-log] { pointer-events: none; }

[data-classic-ultima-game-mode],
[data-classic-ultima-game-mode] * {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
}
[data-classic-ultima-game-mode] input,
[data-classic-ultima-game-mode] textarea,
[data-classic-ultima-game-mode] [contenteditable="true"] {
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}

.classic-world-tap-feedback {
  position: absolute;
  z-index: 6;
  width: 34px;
  height: 34px;
  margin: -17px 0 0 -17px;
  border: 2px solid rgba(255, 240, 168, .95);
  border-radius: 50%;
  background: rgba(221, 194, 98, .13);
  box-shadow: 0 0 0 2px rgba(8, 13, 22, .7), inset 0 0 8px rgba(255, 242, 174, .35);
  pointer-events: none;
  animation: classic-world-tap-ripple 480ms ease-out forwards;
}

@keyframes classic-world-tap-ripple {
  from { opacity: 1; transform: scale(.45); }
  to { opacity: 0; transform: scale(1.25); }
}

@media (prefers-reduced-motion: reduce) {
  .classic-world-tap-feedback { animation-duration: 160ms; transform: none; }
}

[data-platform-mobile-controls],
[data-platform-mobile-controls] button,
[data-platform-mobile-controls] [role="button"] {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

[data-platform-mobile-controls] .mobile-dpad,
[data-platform-mobile-controls] .mobile-dpad button { touch-action: none; }

/* Shared information and menu surfaces. These mirror the established Ultima IV
   hierarchy so later ports can supply content without inventing another shell. */
.classic-dialog,
.classic-journey-sheet {
  color: var(--classic-text, #f0eadc);
  background: var(--classic-panel, #0d1523);
  border: 1px solid var(--classic-line-bright, #3b536e);
  border-radius: 8px;
  box-shadow: 0 20px 70px rgba(0, 0, 0, .65);
}
.classic-dialog::backdrop,
.classic-journey-sheet::backdrop { background: rgba(2, 6, 11, .72); backdrop-filter: blur(3px); }
.classic-dialog__header { border-bottom: 1px solid var(--classic-line, #26364c); background: transparent; }
.classic-dialog__header h2 { color: var(--classic-text, #f0eadc); font: 500 1.45rem/1.1 Georgia, serif; }
.classic-dialog__close,
.classic-journey-sheet__close {
  width: 50px;
  min-width: 50px;
  min-height: 50px;
  padding: 0;
  border: 0;
  border-left: 1px solid var(--classic-line, #26364c);
  background: transparent;
  color: var(--classic-text, #f0eadc);
  font-size: 1.45rem;
  cursor: pointer;
}
.classic-journey-sheet {
  width: min(38rem, calc(100% - 1.5rem));
  height: min(42rem, calc(100dvh - 1.5rem));
  max-height: calc(100dvh - 1.5rem);
  padding: 0;
  overflow: hidden;
}
.classic-journey-sheet[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.classic-journey-sheet__header { display: grid; grid-template-columns: minmax(0, 1fr) 50px; margin: 0; padding: 0; }
.classic-journey-tabs { display: grid; grid-template-columns: repeat(3, 1fr); border-bottom: 1px solid var(--classic-line, #26364c); }
.classic-journey-tabs button {
  position: relative;
  min-width: 0;
  min-height: 52px;
  border: 0;
  border-right: 1px solid var(--classic-line, #26364c);
  background: transparent;
  color: var(--classic-muted, #8f9cac);
  font: inherit;
  cursor: pointer;
}
.classic-journey-tabs button[aria-selected="true"] { color: var(--classic-text, #f0eadc); background: rgba(26, 39, 57, .5); }
.classic-journey-tabs button[aria-selected="true"]::after {
  content: "";
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: -1px;
  height: 2px;
  background: var(--classic-gold, #d5a84d);
}
.classic-journey-panel { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 20px; }
.classic-panel-heading { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 17px; }
.classic-panel-heading h2 { margin: 0; font: 500 1.55rem/1.1 Georgia, serif; }
.classic-panel-heading > span { color: var(--classic-muted, #8f9cac); font-size: .65rem; }
.classic-panel-note { margin: -6px 0 16px; color: var(--classic-muted, #8f9cac); font-size: .72rem; line-height: 1.45; }
.classic-journey-footer { display: flex; align-items: center; justify-content: space-between; min-height: 48px; padding: 0 20px; border-top: 1px solid var(--classic-line, #26364c); color: var(--classic-muted, #8f9cac); font-size: .65rem; }
.classic-journey-footer span { display: flex; align-items: center; gap: 7px; }
.classic-journey-footer i { width: 7px; height: 7px; border-radius: 50%; background: var(--classic-green, #78b86b); box-shadow: 0 0 8px rgba(120, 184, 107, .6); }
.classic-journey-footer button { min-height: 44px; border: 0; background: transparent; color: var(--classic-muted, #8f9cac); font: inherit; cursor: pointer; }
.classic-journey-footer button:hover { color: var(--classic-text, #f0eadc); }

@media (max-width: 650px), (max-width: 980px) and (max-height: 500px) {
  .classic-journey-sheet {
    position: fixed;
    inset: auto max(7px, env(safe-area-inset-right)) 0 max(7px, env(safe-area-inset-left));
    width: auto;
    height: auto;
    max-height: min(78dvh, 660px);
    margin: 0;
    border-bottom: 0;
    border-radius: 12px 12px 0 0;
    box-shadow: 0 -24px 70px rgba(0, 0, 0, .6);
  }
  .classic-journey-sheet[open] { animation: classic-sheet-enter 180ms ease-out; }
  .classic-journey-footer { min-height: calc(52px + env(safe-area-inset-bottom)); padding: 0 16px env(safe-area-inset-bottom); }
  .classic-dialog { border-radius: 8px; }
}

@keyframes classic-sheet-enter {
  from { transform: translateY(calc(100% + 12px)); }
  to { transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .classic-journey-sheet[open] { animation: none; }
}
