/* Retain the existing shared service styles. Dungeon controls below use a
 * separate material treatment; this sheet stays last in the cascade. */
button {
  min-width: 44px;
  min-height: 44px;
  padding: 8px 12px;
  gap: 7px;
  border: 1px solid var(--edge);
  border-radius: 2px;
  outline: none;
  box-shadow: 0 2px 5px rgba(0,0,0,.22);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .02em;
  text-transform: none;
}
button:hover:not(:disabled) { border-color: var(--edge-strong); }
button:focus-visible { outline: 2px solid #f1c66f; outline-offset: 3px; }
button:disabled { opacity: .5; }
button.primary { border-color: #9d7941; }
button.danger { border-color: #804249; }


/* Dungeon controls: cut iron action tokens, with the illustration leading.
 * The physical face is a pseudo-element; focus and touch bounds stay unclipped. */
.combat-controls, .movement-command { font-family: "Segoe UI", system-ui, sans-serif; letter-spacing: 0; }
.combat-controls { position: relative; display: flex; flex-direction: column; align-items: stretch; width: min(580px,calc(100% - 32px)); margin: 0 auto 18px; padding: 0; gap: 9px; background: none; border: 0; border-radius: 0; box-shadow: none; pointer-events: auto; }
.combat-controls:has(.combat-command-grid[data-count="7"]) { width: min(676px,calc(100% - 32px)); }
.combat-controls:has(.combat-command-grid[data-count="8"]) { width: min(772px,calc(100% - 32px)); }
.combat-controls > .control-group.command-heading { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; min-width: 0; gap: 8px; padding: 0 12px; }
.command-heading #combat-status { min-width: 0; width: auto; padding: 0; color: #eee3ca; border: 0; box-shadow: none; background: none; font: 600 12px/1.4 "Segoe UI",system-ui,sans-serif; white-space: normal; text-shadow: 0 1px 3px #000; }
.command-note { max-width: 62%; color: #c7baa1; font: 11px/1.4 "Segoe UI",system-ui,sans-serif; text-align: right; text-shadow: 0 1px 3px #000; }
.command-note[hidden] { display: none; }
.combat-controls > .control-group.combat-command-grid { display: grid; grid-template-columns: repeat(var(--command-count, 6),minmax(0,1fr)); align-items: stretch; gap: 10px; min-width: 0; }
.combat-controls .control-group.combat-command-grid button {
  --token-cut: polygon(12px 0,calc(100% - 12px) 0,100% 12px,100% calc(100% - 12px),calc(100% - 12px) 100%,12px 100%,0 calc(100% - 12px),0 12px);
  --token-edge: #71614c; --token-body: #161817;
  position: relative; isolation: isolate; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 1px; width: 100%; min-width: 0; height: 88px; min-height: 88px; padding: 7px 4px; color: #eadfc8; background: none; border: 0; border-radius: 0; outline: none; box-shadow: none; font-family: "Segoe UI",system-ui,sans-serif; font-weight: 600; letter-spacing: 0; transform: none;
}
.combat-command::before, .movement-command::before { content: ''; position: absolute; inset: 0; z-index: -2; pointer-events: none; clip-path: var(--token-cut); background: linear-gradient(145deg,#c1a273 0,var(--token-edge) 24%,#3a352c 48%,#080b0d 66%,#736047 100%); }
.combat-command::after, .movement-command::after { content: ''; position: absolute; inset: 2px; z-index: -1; pointer-events: none; clip-path: var(--token-cut); background: radial-gradient(ellipse at 40% 0,rgba(187,159,109,.18),transparent 65%),repeating-linear-gradient(110deg,rgba(255,255,255,.018) 0 1px,transparent 1px 4px),linear-gradient(155deg,#292c29 0,var(--token-body) 55%,#101311 100%); box-shadow: inset 0 1px 0 rgba(248,228,187,.15),inset 0 -5px 9px rgba(0,0,0,.35); }
.combat-command-grid #btn-attack, .combat-command-grid #btn-heavy, .combat-command-grid #btn-special, .combat-command-grid #btn-ability-1, .combat-command-grid #btn-ability-2, .combat-command-grid #btn-guard, .combat-command-grid #btn-potion, .combat-command-grid #btn-run { order: initial; grid-column: auto; }
.combat-controls .combat-command-grid #btn-attack { --token-edge: #b18a49; --token-body: #30251a; color: #f4dab0; }
.combat-controls .combat-command-grid #btn-special { --token-edge: #948270; }
.combat-controls .combat-command-grid #btn-run { --token-edge: #494c46; --token-body: #111514; color: #bdb5a7; }
.command-art { position: relative; display: grid; place-items: center; width: 42px; height: 42px; flex: 0 0 auto; }
.command-art img { position: relative; z-index: 1; display: block; width: 100%; height: 100%; object-fit: contain; image-rendering: auto; filter: drop-shadow(0 2px 2px #000) drop-shadow(0 0 4px rgba(222,198,157,.12)); }
#btn-attack .command-art { width: 46px; height: 46px; }
#btn-special .command-art::before { content: ''; position: absolute; inset: -4px; z-index: 0; background: radial-gradient(ellipse,rgba(199,152,61,.36),transparent 70%); }
#btn-special[data-calling="Mage"] .command-art::before { background: radial-gradient(ellipse,rgba(97,186,222,.44),transparent 70%); }
#btn-special[data-calling="Rogue"] .command-art::before { background: radial-gradient(ellipse,rgba(164,117,201,.38),transparent 70%); }
.command-name { display: block; max-width: 100%; font-size: 12px; line-height: 16px; white-space: nowrap; }
.command-cost { display: block; max-width: 100%; min-height: 12px; color: #c4b89f; font-size: 10px; font-weight: 400; line-height: 12px; white-space: nowrap; }
.command-stock { position: absolute; top: 7px; left: 7px; color: #efd5ac; font: 600 10px/12px "Segoe UI",system-ui,sans-serif; }
.combat-command .kbd, .movement-command .kbd { position: absolute; top: 7px; right: 7px; min-width: 0; width: auto; height: auto; margin: 0; padding: 0; border: 0; box-shadow: none; background: none; color: #b7a88d; font: 10px/12px "Segoe UI",system-ui,sans-serif; }
.combat-controls .control-group.combat-command-grid button:hover:not(:disabled), #exploration-ui .movement-command:hover:not(:disabled) { --token-edge: #d4b67b; color: #fff0d1; background: none; transform: none; }
.combat-command:hover:not(:disabled)::after, .movement-command:hover:not(:disabled)::after { background-color: #36362c; filter: brightness(1.18); }
.combat-controls .control-group.combat-command-grid button:focus-visible, #exploration-ui .movement-command:focus-visible { outline: 2px solid #e9ca8f; outline-offset: 3px; border-radius: 8px; }
.combat-controls .control-group.combat-command-grid button:active:not(:disabled), #exploration-ui .movement-command:active:not(:disabled) { transform: translateY(1px); box-shadow: none; }
.combat-controls .control-group.combat-command-grid button:disabled { opacity: .72; }
.combat-command:disabled .command-art { filter: grayscale(.8) brightness(.6); }
.combat-command:disabled .command-name { color: #a79f91; }
.combat-command:disabled .command-cost { color: #cec0a7; }
.combat-controls:has(#combat-status[data-telegraph="heavy"]) #btn-guard:not(:disabled) { --token-edge: #ddb275; --token-body: #303125; }
#combat-log { width: min(490px,calc(100% - 32px)); max-height: 36px; margin: 0 auto 10px; padding: 5px 12px; border: 0; border-radius: 0; background: linear-gradient(90deg,transparent,rgba(8,10,10,.8) 18% 82%,transparent); font: 12px/1.4 "Segoe UI",system-ui,sans-serif; letter-spacing: 0; }
#combat-log p { margin: 1px 0; }

/* A directional pad with a taller forward keystone; exit is kept separate. */
.exploration-controls { padding: 0 18px 18px; }
.movement-cluster { padding: 0; align-items: flex-end; gap: 5px; background: none; border: 0; }
#exploration-ui .movement-command { --token-cut: polygon(10px 0,calc(100% - 10px) 0,100% 10px,100% calc(100% - 10px),calc(100% - 10px) 100%,10px 100%,0 calc(100% - 10px),0 10px); --token-edge: #77654d; --token-body: #171b19; position: relative; isolation: isolate; display: flex; flex-direction: column; justify-content: center; gap: 4px; width: 58px; height: 64px; min-width: 58px !important; min-height: 64px !important; padding: 7px 4px; color: #e6d5b1; border: 0; border-radius: 0; outline: none; background: none; box-shadow: none; font-weight: 600; transform: none; }
#exploration-ui #btn-forward { --token-edge: #b19358; --token-body: #2b2b20; width: 64px; height: 78px; min-width: 64px !important; min-height: 78px !important; margin-bottom: 10px; color: #ffe0a5; }
.movement-command .command-name { font-size: 11px; line-height: 14px; }
.movement-command .command-icon { width: 24px; height: 24px; fill: currentColor; stroke: none; filter: drop-shadow(0 1px 1px #000); }
#exploration-ui .exit-command { --token-edge: #48483e; --token-body: #101513; color: #c8bda6; }

@media (hover: none) and (pointer: coarse) { .combat-command .kbd, .movement-command .kbd { display: none; } }
@media (max-width: 560px) {
  /* The portrait fallback keeps the open floor notice above the pad. */
  #exploration-ui #btn-forward { height: 64px; min-height: 64px !important; margin-bottom: 0; }
  .combat-controls,
  .combat-controls:has(.combat-command-grid[data-count="7"]),
  .combat-controls:has(.combat-command-grid[data-count="8"]) { width: calc(100% - 20px); margin-bottom: 10px; }
  .combat-controls > .control-group.combat-command-grid { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .combat-controls > .control-group.combat-command-grid[data-count="7"],
  .combat-controls > .control-group.combat-command-grid[data-count="8"] { grid-template-columns: repeat(4,minmax(0,1fr)); }
  .combat-command-grid #btn-guard { grid-column: auto; }
  .command-heading #combat-status { width: auto; } .command-note { max-width: 58%; }
}
.in-training .combat-controls .control-group.combat-command-grid button { height: auto; min-height: 88px; align-self: stretch; }
.in-training .training-action-reason { max-width: 100%; white-space: normal; overflow-wrap: anywhere; font: 10px/1.2 "Segoe UI",system-ui,sans-serif; }
@media (prefers-reduced-motion: reduce) { .combat-command, .movement-command { transition: none; } }
